Not apply styles defined
开发者_StackOverflow社区i created a ResourceDictionary , and defined a style for Windows
<Style TargetType="{x:Type Window}" x:Key="WindowDefaultStyle">
<Setter Property="FontFamily" Value="Tahoma" />
<Setter Property="FlowDirection" Value="RightToLeft" />
<Setter Property="FontSize" Value="11" />
</Style>
<!-- Window file -->
<Window Style="{DynamicResource ResourceKey=WindowDefaultStyle}">
apply style in design but when run program not apply.:(
Note: I have updated my code so other people can simply use it.
Try setting the x:Key
on the Style along with TargetType like this -
<Style x:Key="{x:Type Window}" TargetType="{x:Type Window}">
<Setter Property="FontFamily" Value="Tahoma" />
<Setter Property="FlowDirection" Value="RightToLeft" />
<Setter Property="FontSize" Value="11" />
</Style>
Edit: You need to explicitly apply style to your window by giving your style some key. For reference please see these links -
WPF window style not being applied
How to set default WPF Window Style in app.xaml?
精彩评论