开发者

Not apply styles defined

开发者 https://www.devze.com 2023-04-13 02:26 出处:网络
开发者_StackOverflow社区i created a ResourceDictionary , and defined a style for Windows <Style TargetType=\"{x:Type Window}\"x:Key=\"WindowDefaultStyle\">

开发者_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

精彩评论

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