-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainWindow.xaml
76 lines (72 loc) · 2.99 KB
/
MainWindow.xaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?xml version="1.0" encoding="utf-8"?>
<Window
x:Class="TreeViewCollapsingIssue.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:TreeViewCollapsingIssue"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="TreeViewCollapsingIssue">
<Grid
VerticalAlignment="Top"
HorizontalAlignment="Left"
Height="300"
Width="250"
BorderThickness="1"
BorderBrush="{ThemeResource SystemControlForegroundBaseMediumLowBrush}"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.Resources>
<local:TreeViewTemplateSelector x:Key="TreeViewTemplateSelector">
<local:TreeViewTemplateSelector.GroupTemplate>
<DataTemplate x:DataType="local:TreeViewTestGroupItem">
<TreeViewItem
Content="{x:Bind Title}"
ItemsSource="{x:Bind MembersItemSource, Mode=OneWay}"
FontWeight="SemiBold"/>
</DataTemplate>
</local:TreeViewTemplateSelector.GroupTemplate>
<local:TreeViewTemplateSelector.MemberTemplate>
<DataTemplate x:DataType="local:TreeViewTestMemberItem">
<TreeViewItem
Content="{x:Bind Name}"
Height="40"/>
</DataTemplate>
</local:TreeViewTemplateSelector.MemberTemplate>
</local:TreeViewTemplateSelector>
</Grid.Resources>
<TreeView
ItemTemplateSelector="{StaticResource TreeViewTemplateSelector}"
ItemsSource="{x:Bind GroupsItemSource}"
SelectionMode="None"
Grid.Row="0"
Margin="0, 0, 0, 10"
Width="200">
<TreeView.ItemContainerStyle>
<Style TargetType="TreeViewItem">
<Setter Property="IsExpanded" Value="True"/>
</Style>
</TreeView.ItemContainerStyle>
</TreeView>
<StackPanel
Grid.Row="1"
HorizontalAlignment="Center">
<StackPanel.Resources>
<Style TargetType="Button">
<Setter Property="Width" Value="200"/>
<Setter Property="Margin" Value="0, 0, 0, 10"/>
</Style>
</StackPanel.Resources>
<Button
Click="Button_Click_1"
Content="Remove Item"/>
<Button
Click="Button_Click_2"
Content="Restore Item"/>
</StackPanel>
</Grid>
</Window>