Tuesday, 22 September 2009

WPF: Defining a style based on the base style

<Style TargetType="ToggleButton" BasedOn="{StaticResource {x:Type ToggleButton}}">

The VS2008 IDE fails to render the XAML correctly if you try to modify an existing Style for a Component. It does still compile and excute correctly however.

A ListViewItem Style for example:

<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem" BasedOn="{StaticResource {x:Type ListViewItem}}">
<Style.Triggers>
<Trigger Property="ListViewItem.IsMouseOver" Value="True">
<Setter Property="ListViewItem.IsSelected" Value="true"></Setter>
</Trigger>
</Style.Triggers>
</Style>

No comments:

Post a Comment