Use fluent UI for ArchiveFileListView

TreeView style is from WPF-UI
This commit is contained in:
ema
2024-12-08 04:40:02 +08:00
parent 54fed86f2e
commit 619f16bf88

View File

@@ -1,13 +1,13 @@
<UserControl x:Class="QuickLook.Plugin.ArchiveViewer.ArchiveFileListView" <UserControl x:Class="QuickLook.Plugin.ArchiveViewer.ArchiveFileListView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:QuickLook.Plugin.ArchiveViewer" xmlns:local="clr-namespace:QuickLook.Plugin.ArchiveViewer"
mc:Ignorable="d" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DesignHeight="300" d:DesignWidth="300"> d:DesignHeight="300"
<Grid Grid.IsSharedSizeScope="True" d:DesignWidth="300"
x:Name="treeGrid"> mc:Ignorable="d">
<Grid x:Name="treeGrid" Grid.IsSharedSizeScope="True">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<!-- Header row --> <!-- Header row -->
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
@@ -26,8 +26,7 @@
<local:LevelToBooleanConverter x:Key="LevelToBooleanConverter" /> <local:LevelToBooleanConverter x:Key="LevelToBooleanConverter" />
<!-- Template for directory information at all levels --> <!-- Template for directory information at all levels -->
<HierarchicalDataTemplate ItemsSource="{Binding Children.Keys}" <HierarchicalDataTemplate DataType="{x:Type local:ArchiveFileEntry}" ItemsSource="{Binding Children.Keys}">
DataType="{x:Type local:ArchiveFileEntry}">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="2" /> <RowDefinition Height="2" />
@@ -35,8 +34,10 @@
<RowDefinition Height="2" /> <RowDefinition Height="2" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid Grid.Row="1" ShowGridLines="False"> <Grid Grid.Row="1" ShowGridLines="False">
<!-- All column widths are shared except for column 1 which is sized <!--
to compensate for different indentation at each level --> All column widths are shared except for column 1 which is sized
to compensate for different indentation at each level
-->
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition MinWidth="300" SharedSizeGroup="rowHeaderColumn" /> <ColumnDefinition MinWidth="300" SharedSizeGroup="rowHeaderColumn" />
<ColumnDefinition /> <ColumnDefinition />
@@ -53,15 +54,13 @@
</Image.Source> </Image.Source>
</Image> </Image>
<TextBlock Text="{Binding Name}" /> <TextBlock Text="{Binding Name}" />
<TextBlock <TextBlock Text="{Binding Encrypted, Converter={StaticResource BooleanToAsteriskConverter}}" />
Text="{Binding Encrypted, Converter={StaticResource BooleanToAsteriskConverter}}" />
</StackPanel> </StackPanel>
<Rectangle Grid.Column="1"> <Rectangle Grid.Column="1">
<Rectangle.Width> <Rectangle.Width>
<MultiBinding Converter="{StaticResource LevelToIndentConverter}"> <MultiBinding Converter="{StaticResource LevelToIndentConverter}">
<Binding Path="Level" /> <Binding Path="Level" />
<Binding ElementName="treeViewItemToMeasure" <Binding ElementName="treeViewItemToMeasure" Path="ActualWidth" />
Path="ActualWidth" />
</MultiBinding> </MultiBinding>
</Rectangle.Width> </Rectangle.Width>
</Rectangle> </Rectangle>
@@ -88,7 +87,9 @@
<!-- Tree view with one item for the header row --> <!-- Tree view with one item for the header row -->
<TreeView BorderThickness="0" Focusable="False" Background="Transparent" <TreeView Background="Transparent"
BorderThickness="0"
Focusable="False"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"> ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<TreeViewItem Focusable="False" Visibility="Collapsed"> <TreeViewItem Focusable="False" Visibility="Collapsed">
<TreeViewItem.Header> <TreeViewItem.Header>
@@ -99,28 +100,25 @@
<ColumnDefinition SharedSizeGroup="column1" /> <ColumnDefinition SharedSizeGroup="column1" />
<ColumnDefinition SharedSizeGroup="column2" /> <ColumnDefinition SharedSizeGroup="column2" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" <TextBlock Grid.Column="0" Text=" " />
Text=" " />
<TreeViewItem Grid.Column="1"> <TreeViewItem Grid.Column="1">
<TreeViewItem.Header> <TreeViewItem.Header>
<TreeViewItem x:Name="treeViewItemToMeasure" <TreeViewItem x:Name="treeViewItemToMeasure" Padding="0" />
Padding="0" />
</TreeViewItem.Header> </TreeViewItem.Header>
<!-- Set the width of Column 1 to the same width as the top level <!--
in the data --> Set the width of Column 1 to the same width as the top level
in the data
-->
<TreeViewItem.Width> <TreeViewItem.Width>
<MultiBinding Converter="{StaticResource LevelToIndentConverter}"> <MultiBinding Converter="{StaticResource LevelToIndentConverter}">
<Binding Path="Level" /> <Binding Path="Level" />
<Binding ElementName="treeViewItemToMeasure" <Binding ElementName="treeViewItemToMeasure" Path="ActualWidth" />
Path="ActualWidth" />
</MultiBinding> </MultiBinding>
</TreeViewItem.Width> </TreeViewItem.Width>
</TreeViewItem> </TreeViewItem>
<TextBlock Grid.Column="2" <TextBlock Grid.Column="2" Text="Original Size" />
Text="Original Size" /> <TextBlock Grid.Column="3" Text="Modified Date" />
<TextBlock Grid.Column="3"
Text="Modified Date" />
</Grid> </Grid>
</TreeViewItem.Header> </TreeViewItem.Header>
</TreeViewItem> </TreeViewItem>
@@ -128,15 +126,8 @@
<!-- Tree view that will display hierarchical data rows --> <!-- Tree view that will display hierarchical data rows -->
<TreeView Grid.Row="1" <TreeView x:Name="treeView"
x:Name="treeView" Grid.Row="1"
BorderThickness="0" Background="Transparent" Foreground="{Binding Foreground, RelativeSource={RelativeSource AncestorType=local:ArchiveFileListView}}" ItemsSource="{Binding}" />
ItemsSource="{Binding}">
<TreeView.ItemContainerStyle>
<Style TargetType="{x:Type TreeViewItem}">
<Setter Property="Foreground" Value="{Binding Foreground, RelativeSource={RelativeSource AncestorType=TreeView}}" />
</Style>
</TreeView.ItemContainerStyle>
</TreeView>
</Grid> </Grid>
</UserControl> </UserControl>