开发者

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:Keyon 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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜