Skip to content

Added theme-specific background for XAML code errors #3588

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
6 commits merged into from
Dec 5, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions Microsoft.Toolkit.Uwp.SampleApp/Controls/XamlCodeEditor.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public sealed partial class XamlCodeEditor : UserControl
public static readonly DependencyProperty TextProperty =
DependencyProperty.Register(nameof(Text), typeof(string), typeof(XamlCodeEditor), new PropertyMetadata(string.Empty));

private ThemeListener _themeListener = new ThemeListener();

public XamlCodeEditor()
{
this.InitializeComponent();
Expand All @@ -40,7 +42,7 @@ public async void ReportError(XamlExceptionRange error)
// Highlight Error Line
XamlCodeRenderer.Decorations.Add(new IModelDeltaDecoration(
range,
new IModelDecorationOptions() { IsWholeLine = true, ClassName = _errorStyle, HoverMessage = new string[] { error.Message }.ToMarkdownString() }));
new IModelDecorationOptions() { IsWholeLine = true, ClassName = ErrorStyle, HoverMessage = new string[] { error.Message }.ToMarkdownString() }));

// Show Glyph Icon
XamlCodeRenderer.Decorations.Add(new IModelDeltaDecoration(
Expand Down Expand Up @@ -121,10 +123,12 @@ public string Text

public DateTime TimeSampleEditedLast { get; private set; } = DateTime.MinValue;

private CssLineStyle _errorStyle = new CssLineStyle()
private CssLineStyle ErrorStyle
{
BackgroundColor = new SolidColorBrush(Color.FromArgb(0x00, 0xFF, 0xD6, 0xD6))
};
get => _themeListener.CurrentTheme.Equals(ApplicationTheme.Light) ?
new CssLineStyle() { BackgroundColor = new SolidColorBrush(Color.FromArgb(0x00, 0xFF, 0xD6, 0xD6)) } :
new CssLineStyle() { BackgroundColor = new SolidColorBrush(Color.FromArgb(0x00, 0x66, 0x00, 0x00)) };
}

private CssGlyphStyle _errorIconStyle = new CssGlyphStyle()
{
Expand Down