Tuesday 29 June 2010

Expanded TreeViewItem Style in Silverlight TreeView

By default TreeView item child is not expanded. It remains collapsed. To make it expanded we have to apply following style in .xaml page where TreeViwe controls are used.


<controls:TreeView x:Name="trvLeftMenu"  BorderThickness="0,1,0,0" Margin="0" Width="auto"  HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
                                       ItemContainerStyle="{StaticResource expandedTreeViewItemStyle}">
</controls:TreeView>

ItemContainerStyle – is the expand property.
expandedTreeViewItemStyle – is the name of style.

Below is the calling style.

<UserControl.Resources>
<Style x:Key="expandedTreeViewItemStyle" TargetType="controls:TreeViewItem">
            <Setter Property="IsExpanded" Value="True" />
</Style>
</UserControl.Resources>


No comments:

Post a Comment