kravindra
asked on
How to expand and select first treeview item by default in treeview control in WPF
<TreeView Height="288" HorizontalAlignment="Left" Margin="18,23,0,0" VerticalAlignment="Top" Width="89"
x:Name="tvCita" ItemsSource="{Binding CitaCol,Mode=TwoWay}" ItemTemplate="{StaticResou rce MasterTemplate}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectedItemCha nged">
<cmd:EventToCommand Command="{Binding TreeviewItemClick}" CommandParameter="{Binding SelectedItem, ElementName= tvCita, Mode=OneWay}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</TreeView>
<DataTemplate x:Key="DetailTemplate">
<TextBlock Text="{Binding Swift_File_Name}"/>
</DataTemplate>
<HierarchicalDataTemplate x:Key="MasterTemplate"
ItemsSource="{ Binding SwiftCol,Mode=TwoWay}"
ItemTemplate="{StaticResou rce DetailTemplate}">
<TextBlock Text="{Binding CITA_Info_Id}"/>
</HierarchicalDataTemplate >
I tried like this , but I am getting error
I created style under window.resource
<Style TargetType="TreeViewItem">
<Setter Property="IsExpanded" Value="True" />
</Style>
I called this style in treeview control like this style="<staticResource TreeViewItem>
but i am getting runtime exception like this
'Set property 'System.Windows.FrameworkE lement.Sty le' threw an exception.' Line number '40' and line position '79'.
How to fix it or How to expand and select first treeview item by default in treeview control in WPF
x:Name="tvCita" ItemsSource="{Binding CitaCol,Mode=TwoWay}" ItemTemplate="{StaticResou
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectedItemCha
<cmd:EventToCommand Command="{Binding TreeviewItemClick}" CommandParameter="{Binding
</i:EventTrigger>
</i:Interaction.Triggers>
</TreeView>
<DataTemplate x:Key="DetailTemplate">
<TextBlock Text="{Binding Swift_File_Name}"/>
</DataTemplate>
<HierarchicalDataTemplate x:Key="MasterTemplate"
ItemsSource="{ Binding SwiftCol,Mode=TwoWay}"
ItemTemplate="{StaticResou
<TextBlock Text="{Binding CITA_Info_Id}"/>
</HierarchicalDataTemplate
I tried like this , but I am getting error
I created style under window.resource
<Style TargetType="TreeViewItem">
<Setter Property="IsExpanded" Value="True" />
</Style>
I called this style in treeview control like this style="<staticResource TreeViewItem>
but i am getting runtime exception like this
'Set property 'System.Windows.FrameworkE
How to fix it or How to expand and select first treeview item by default in treeview control in WPF
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.