1

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.

ar.gorgin
  • 4,765
  • 12
  • 61
  • 100

1 Answers1

0

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?

Community
  • 1
  • 1
Rohit Vats
  • 79,502
  • 12
  • 161
  • 185
  • Is this Resource dictionary in your seperate file? If yes have you add the reference to it in your file? Can you show the code where you are using it and how you import this Resource dictionary in your file – Rohit Vats Oct 16 '11 at 08:44
  • yes i use a seperate file,and add this code in app.xaml... – ar.gorgin Oct 16 '11 at 08:51