I have this XAML. If I remove the StackPanel.Resources section I get the styles that were defined at the application level. If I leave it in, then I only get the new styles.
How to I make it combine both the local and global styles?
<Window x:Class="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">
<DockPanel>
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal" >
<StackPanel.Resources>
<Style TargetType="TextBlock" >
<Setter Property="Margin" Value="4" />
</Style>
<Style TargetType="Button" >
<Setter Property="Margin" Value="4" />
</Style>
</StackPanel.Resources>
<Border Padding="5" BorderBrush="Blue" BorderThickness="4" >
<StackPanel>
<TextBlock>Applications</TextBlock>
<Button>Open Issues</Button>
<Button>Services</Button>
</StackPanel>
</Border>
</StackPanel>
<StackPanel></StackPanel>
</DockPanel>
</Window>
In case it helps, this is how I defined the globla styles.
<Application x:Class="Application"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary Source="ShinyBlue.xaml"/>
</Application.Resources>
</Application>
To Combine the application Level + Local Resource
in the local resource definition
<Style TargetType="TextBlock" BasedOn="{StaticResource StyleA}" >
<Setter Property="Margin" Value="4" />
</Style>
This will give you style from app level as well the local level
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With