Reputation: 6500
Quite odd scenario. I have the following App.xaml
<Application x:Class="BrokenBG.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
<Style x:Key="WindowStyleBase" TargetType="ContentControl" >
<Setter Property="Background" Value="Red" />
</Style>
<Style x:Key="WindowStyle" TargetType="{x:Type Window}" BasedOn="{StaticResource WindowStyleBase}" />
</Application.Resources>
</Application>
And a plain empty window with the style set:
<Window x:Class="BrokenBG.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525" Style="{StaticResource WindowStyle}">
<Grid>
</Grid>
</Window>
When I run the app all is fine. I see the red bg. But I cannot see it in the designer. The code above is a repro case I've experienced in another larger project.
When I change Window Style from WindowStyle
to WindowStyleBase
then I can directly see the red background color in the designer.
Can this be fixed? My windows have a dark theme, therefore I cannot design the views in Visual Studio / Blend since the background is white and black during runtime (my text is white)
It looks like the designer has issues with BasedOn parsing? (unsure)
Upvotes: 2
Views: 228
Reputation: 5262
One thing that works, even though it won't compile. You can change staticresource in the based on to dynamic resource.
It'll suddenly start working in designer, but this won't compile.
I even changed red to blue, and the designer updated.
Upvotes: 2