Inherit styles in Windows Presentation Fondation
Few moment ago I faced to problem, how to create style which just add some behaviors to existing style.
In my case I just needed create close button. This close button change background color when mouse is over and when button is pressed.
<Style x:Key="WindowCloseButtonStyle" TargetType="{x:Type Button}" BasedOn="{StaticResource WindowButtonStyle}">
<Style.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="Control.IsMouseOver" Value="true"></Condition>
<Condition Property="Button.IsPressed" Value="false"></Condition>
</MultiTrigger.Conditions>
<Setter Property="Control.Background" Value="{DynamicResource DangerColorBrush}"></Setter>
</MultiTrigger>
</Style.Triggers>
</Style>
Important part in this example is BaseOn attribute of style element.
Written by Sebastian Bušek
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#.net
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#