Browse Source

Initialize DevTools MainWindow theme in code.

Previously if no theme was included in App.xaml, then DevTools would fail to open because the `StaticResource` lookup would fail due to the window's XAML not being parsed yet.
pull/9214/head
Steven Kirk 4 years ago
parent
commit
6cc1215989
  1. 3
      src/Avalonia.Diagnostics/Diagnostics/Views/MainWindow.xaml
  2. 5
      src/Avalonia.Diagnostics/Diagnostics/Views/MainWindow.xaml.cs

3
src/Avalonia.Diagnostics/Diagnostics/Views/MainWindow.xaml

@ -3,8 +3,7 @@
xmlns:views="clr-namespace:Avalonia.Diagnostics.Views"
xmlns:diag="clr-namespace:Avalonia.Diagnostics"
Title="Avalonia DevTools"
x:Class="Avalonia.Diagnostics.Views.MainWindow"
Theme="{StaticResource {x:Type Window}}">
x:Class="Avalonia.Diagnostics.Views.MainWindow">
<Window.DataTemplates>
<diag:ViewLocator/>
</Window.DataTemplates>

5
src/Avalonia.Diagnostics/Diagnostics/Views/MainWindow.xaml.cs

@ -28,6 +28,11 @@ namespace Avalonia.Diagnostics.Views
{
InitializeComponent();
// Apply the SimpleTheme.Window theme; this must be done after the XAML is parsed as
// the theme is included in the MainWindow's XAML.
if (Theme is null && this.FindResource(typeof(Window)) is ControlTheme windowTheme)
Theme = windowTheme;
_keySubscription = InputManager.Instance?.Process
.OfType<RawKeyEventArgs>()
.Where(x => x.Type == RawKeyEventType.KeyDown)

Loading…
Cancel
Save