Mega Code Archive

 
Categories / C# / WPF
 

Add a logical resource to the windows resource dictionary

<Window x:Class="WpfApplication1.MainWindow"   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"   Title="FunWithResources" Height="207" Width="612" WindowStartupLocation="CenterScreen">   <Window.Resources>     <Style x:Key ="MyFunkyStyle">       <Setter Property ="Control.FontSize" Value ="20"/>       <Setter Property ="Control.Background">         <Setter.Value>           <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">             <GradientStop Color="Green" Offset="0" />             <GradientStop Color="Yellow" Offset="0.25" />           </LinearGradientBrush>         </Setter.Value>       </Setter>     </Style>     <Style x:Key ="NewFunkyStyle" BasedOn = "{StaticResource MyFunkyStyle}">       <Setter Property = "Button.Foreground" Value = "Blue"/>       <Setter Property = "Button.RenderTransform">         <Setter.Value>           <RotateTransform Angle = "20"/>         </Setter.Value>       </Setter>     </Style>   </Window.Resources>   <StackPanel>     <Image Name ="companyLogo" Source ="c:\image.gif"/>     <Button Name="btnClickMe" Style ="{StaticResource NewFunkyStyle}" Content = "Click Me"/>     <Button Name="btnClickMeToo" Style ="{StaticResource NewFunkyStyle}" Content = "Me Too"/>     <TextBox Name="txtAndMe" Style ="{StaticResource MyFunkyStyle}" Text = "And me!"/>   </StackPanel> </Window>