Skip to content

Commit

Permalink
Tidy up TreeView demo page
Browse files Browse the repository at this point in the history
  • Loading branch information
apman committed Jan 7, 2025
1 parent 3386702 commit a8c524e
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 24 deletions.
6 changes: 6 additions & 0 deletions samples/SampleApp/Assets/Folder.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions samples/SampleApp/Assets/_index.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@

<!-- Each asset listed here also needs to be registered in `SampleApp.csproj` as `<AdditionalFiles ...>` -->
<SKPictureImage x:Key="PadlockIcon" Source="{x:Static local:Padlock.Picture}" />
<SKPictureImage x:Key="FolderIcon" Source="{x:Static local:Folder.Picture}" />

</ResourceDictionary>
113 changes: 89 additions & 24 deletions samples/SampleApp/DemoPages/TreeViewDemo.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,46 +5,111 @@
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="SampleApp.DemoPages.TreeViewDemo">


<StackPanel Orientation="Horizontal" Spacing="30" VerticalAlignment="Top">
<TreeView Width="150">
<TreeViewItem Header="Level 1.1" IsExpanded="True">
<TreeViewItem Header="Level 2.1" IsSelected="True" IsExpanded="True">
<TreeViewItem Header="Level 3.1" />
<TreeViewItem Header="Level 3.2">
<TreeViewItem Header="Level 4.1" />
<TreeViewItem Header="Level 4.2" />
<TreeViewItem Header="Level 4.3" />

</TreeViewItem>
</TreeViewItem>
<TreeViewItem Header="Level 2.2" IsEnabled="False" />
</TreeViewItem>
</TreeView>

<!-- With icons -->
<TreeView Width="150">
<TreeViewItem IsExpanded="True">
<TreeViewItem.Header>
<StackPanel Orientation="Horizontal" Spacing="5">
<Image Source="{StaticResource FolderIcon}" Width="16" Height="16" />
<TextBlock>Level 1.1</TextBlock>
</StackPanel>
</TreeViewItem.Header>
<TreeViewItem IsExpanded="True">
<TreeViewItem.Header>
<StackPanel Orientation="Horizontal" Spacing="5">
<Image Source="{StaticResource FolderIcon}" Width="16" Height="16" />
<TextBlock>Level 2.1</TextBlock>
</StackPanel>
</TreeViewItem.Header>
<TreeViewItem>
<TreeViewItem.Header>
<StackPanel Orientation="Horizontal" Spacing="5">
<Image Source="{StaticResource FolderIcon}" Width="16" Height="16" />
<TextBlock>Level 3.1</TextBlock>
</StackPanel>
</TreeViewItem.Header>
</TreeViewItem>
<TreeViewItem>
<TreeViewItem.Header>
<StackPanel Orientation="Horizontal" Spacing="5">
<Image Source="{StaticResource FolderIcon}" Width="16" Height="16" />
<TextBlock>Level 3.2</TextBlock>
</StackPanel>
</TreeViewItem.Header>
</TreeViewItem>
<TreeViewItem>
<TreeViewItem.Header>
<StackPanel Orientation="Horizontal" Spacing="5">
<Image Source="{StaticResource FolderIcon}" Width="16" Height="16" />
<TextBlock>Level 3.3</TextBlock>
</StackPanel>
</TreeViewItem.Header>
<TreeViewItem>
<TreeViewItem.Header>
<StackPanel Orientation="Horizontal">
<TextBlock>Icon</TextBlock>
<TextBlock>Level 4</TextBlock>
<StackPanel Orientation="Horizontal" Spacing="5">
<Image Source="{StaticResource FolderIcon}" Width="16" Height="16" />
<TextBlock>Level 4.1</TextBlock>
</StackPanel>
</TreeViewItem.Header>
<TreeViewItem Header="Level 4.1" />
<TreeViewItem Header="Level 4.2" />
</TreeViewItem>
<TreeViewItem>
<TreeViewItem.Header>
<StackPanel Orientation="Horizontal" Spacing="5">
<Image Source="{StaticResource FolderIcon}" Width="16" Height="16" />
<TextBlock>Level 4.2</TextBlock>
</StackPanel>
</TreeViewItem.Header>
</TreeViewItem>
<TreeViewItem IsEnabled="False" />
</TreeViewItem>
</TreeViewItem>
<TreeViewItem Header="Level 2.2" IsEnabled="False" />
</TreeViewItem>
</TreeView>
<TreeView Width="150" Height="160" Classes="AlternatingRowColor" BorderBrush="LightGray" BorderThickness="1">
<TreeViewItem Header="Level 1.1" >
<TreeViewItem Header="Level 2.1" />
<TreeViewItem Header="Level 2.2" />
<TreeViewItem Header="Level 2.3" />
<TreeViewItem Header="Level 2.4" />
<TreeViewItem Header="Level 2.5" />
<TreeViewItem Header="Level 2.6" />
<TreeViewItem Header="Level 2.7">
<TreeViewItem Header="Level 3.1" />
<TreeViewItem Header="Level 3.2" IsSelected="True" />
<TreeViewItem Header="Level 3.3">
<TreeViewItem Header="Level 4.1" />
<TreeViewItem Header="Level 4.2" />

<!-- With alternating row colour & scrolling -->
<StackPanel Spacing="20">

<TreeView Width="150" Height="160" Classes="AlternatingRowColor" BorderBrush="LightGray" BorderThickness="1">
<TreeViewItem Header="Level 1.1">
<TreeViewItem Header="Level 2.1" />
<TreeViewItem Header="Level 2.2" />
<TreeViewItem Header="Level 2.3" />
<TreeViewItem Header="Level 2.4" />
<TreeViewItem Header="Level 2.5" />
<TreeViewItem Header="Level 2.6" />
<TreeViewItem Header="Level 2.7">
<TreeViewItem Header="Level 3.1" />
<TreeViewItem Header="Level 3.2" IsSelected="True" />
<TreeViewItem Header="Level 3.3">
<TreeViewItem Header="Level 4.1" />
<TreeViewItem Header="Level 4.2" />
</TreeViewItem>
</TreeViewItem>
<TreeViewItem Header="Level 2.8" IsEnabled="False" />
</TreeViewItem>
<TreeViewItem Header="Level 2.8" IsEnabled="False" />
</TreeViewItem>
<TreeViewItem Header="Level 1.2" />
</TreeView>
<TreeViewItem Header="Level 1.2" />
</TreeView>
<TextBlock TextWrapping="Wrap" HorizontalAlignment="Center">
For alternating row colour use: <LineBreak />
<TextBlock Classes="code" FontSize="13" Text="Classes=&quot;AlternatingRowColor&quot;" />
</TextBlock>
</StackPanel>
</StackPanel>
</UserControl>
1 change: 1 addition & 0 deletions samples/SampleApp/SampleApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

<ItemGroup>
<AdditionalFiles Include="Assets/Padlock.svg" NamespaceName="SampleApp" ClassName="Padlock"/>
<AdditionalFiles Include="Assets/Folder.svg" NamespaceName="SampleApp" ClassName="Folder"/>
</ItemGroup>

<!-- Temporary link for development.
Expand Down

0 comments on commit a8c524e

Please sign in to comment.