Calender

S M T W T F S
   1234
567891011
12131415161718
19202122232425
262728293031 
<< August 2018 >>

Categories

Archives

Recent Entries

Recent Comment

Recent Trackback

w closet×JUGEM

-

Setting up WPF treeview triggers to show different images on expand - Stack Overflow

@media print { body { margin: 2mm 9mm; } .original-url { display: none; } #article .float.left { float: left !important; } #article .float.right { float: right !important; } #article .float { margin-top: 0 !important; margin-bottom: 0 !important; } } Setting up WPF treeview triggers to show different images on expand - Stack Overflow

Setting up WPF treeview triggers to show different images on expand

<UserControl.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="../Theme.xaml" /> </ResourceDictionary.MergedDictionaries> <HierarchicalDataTemplate DataType="{x:Type vm:SolutionsViewModel}" ItemsSource="{Binding Items}"> <StackPanel Orientation="Horizontal"> <Image x:Name="nodeImg" Width="16" Height="16" Source="pack://siteOfOrigin:,,,/Resources/FolderClosed.bmp"/> <TextBlock Margin="5,0,0,0" Text="{Binding Name}" /> </StackPanel> <HierarchicalDataTemplate.Triggers> <DataTrigger Binding="{Binding IsExpanded}" Value="True"> <Setter TargetName="nodeImg" Property="Source" Value="pack://siteOfOrigin:,,,/Resources//FolderOpen.bmp"/> </DataTrigger> </HierarchicalDataTemplate.Triggers> </HierarchicalDataTemplate> <HierarchicalDataTemplate DataType="{x:Type sol:Solution}" ItemsSource="{Binding Items}"> <StackPanel Orientation="Horizontal"> <Image x:Name="treeImg" Width="16" Height="16" Source="pack://siteOfOrigin:,,,/Resources/SolutionClosed.bmp"/> <TextBlock Margin="5,0,0,0" Text="{Binding Name}" /> </StackPanel> <HierarchicalDataTemplate.Triggers> <DataTrigger Binding="{Binding IsExpanded}" Value="True"> <Setter TargetName="treeImg" Property="Source" Value="pack://siteOfOrigin:,,,/Resources//SolutionOpen.bmp"/> </DataTrigger> </HierarchicalDataTemplate.Triggers> </HierarchicalDataTemplate> <HierarchicalDataTemplate DataType="{x:Type vm:ConventionsViewModel}" ItemsSource="{Binding Items}"> <StackPanel Orientation="Horizontal"> <Image x:Name="nodeImg" Width="16" Height="16" Source="pack://siteOfOrigin:,,,/Resources/FolderClosed.bmp"/> <TextBlock Margin="5,0,0,0" Text="{Binding Name}" /> </StackPanel> <HierarchicalDataTemplate.Triggers> <DataTrigger Binding="{Binding IsExpanded}" Value="True"> <Setter TargetName="nodeImg" Property="Source" Value="pack://siteOfOrigin:,,,/Resources//FolderOpen.bmp"/> </DataTrigger> </HierarchicalDataTemplate.Triggers> </HierarchicalDataTemplate> </ResourceDictionary> </UserControl.Resources> <UserControl.DataContext> <ObjectDataProvider ObjectType="{x:Type vm:TreeViewModel}" MethodName="CreateDefaultTree" /> </UserControl.DataContext> <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto"> <Grid> <TreeView Name="solutionsModel" ItemsSource="{Binding Items}"> <TreeView.ItemContainerStyle> <Style TargetType="{x:Type TreeViewItem}"> <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" /> <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" /> <Setter Property="FontWeight" Value="Normal" /> <Style.Triggers> <Trigger Property="IsSelected" Value="True"> <Setter Property="FontWeight" Value="Bold" /> </Trigger> </Style.Triggers> </Style> </TreeView.ItemContainerStyle> </TreeView> </Grid> </ScrollViewer>


iPadから送信
  • 2018.08.09 Thursday
  • 19:16

Comment
Send Comment








   
この記事のトラックバックURL
Trackback