sss hima

sss hima

  • 0
  • 6
  • 0

Dynamic Resource Style in WPF

Feb 18 2010 11:50 PM

Hi All,
In my WPF application I Wrote some styles for button in App.xaml and in my Window.xaml    I mentioned Style="{DynamicResource MyStyle1}" for a button but that style is not getting reflected when i run the application. Let me know how do i get those styles..

This is the code i placed in App.xaml
<Application x:Class="WpfInDetail.App"
<Style x:Name="MyButtonStyle" TargetType="Button">
<Setter Property="Foreground" Value="Red" />
<Setter Property="Background" Value="Yellow"></Setter>
<Setter Property="FontSize" Value="14"></Setter>

and the following is the code in window. xaml
<Window x:Class="WpfInDetail.Window2"
Title="Window2" Height="300" Width="300">
<StackPanel >
<Button Name="MyTextBlock" Height="50" Width="80" VerticalAlignment="Center" HorizontalAlignment="Center" Style="{DynamicResource MyButtonStyle}" Content="Hyma...." />

Now as i added i am not getting the styles reflected in UI let me know if there are any issues in thecode and what is a Dynamic Resource in WPF


Brought to you by:

Answers (2)