Tuesday, August 7, 2012

WPF Style overriding


GLOBAL
--------------------------------------------------------------------------------
<Style BasedOn="{StaticResource {x:Type ListViewItem}}"
                    TargetType="ListViewItem">
            <Setter Property="VerticalContentAlignment" Value="Top" />
        </Style>

Use BasedOn to inherit from existing style, Then override only the line needed.


InLine
----------------------------------------------------------------------------------

<ListView.ItemContainerStyle>
                            <Style BasedOn="{StaticResource {x:Type ListViewItem}}"
                               TargetType="ListViewItem">
                                <Setter Property="VerticalContentAlignment" Value="Top" />
                            </Style>
                        </ListView.ItemContainerStyle>