mirror of
https://gitcode.com/gh_mirrors/se/Semi.Avalonia
synced 2026-03-03 00:00:55 +08:00
feat: enhance demo.
This commit is contained in:
@@ -3,15 +3,13 @@ using System.Collections.Generic;
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Data.Converters;
|
using Avalonia.Data.Converters;
|
||||||
using Avalonia.Media;
|
|
||||||
using Avalonia.Metadata;
|
using Avalonia.Metadata;
|
||||||
|
|
||||||
namespace Semi.Avalonia.TreeDataGrid.Demo.Converters;
|
namespace Semi.Avalonia.TreeDataGrid.Demo.Converters;
|
||||||
|
|
||||||
public class FileIconConverter: IMultiValueConverter
|
public class FileIconConverter : IMultiValueConverter
|
||||||
{
|
{
|
||||||
[Content]
|
[Content] public IDictionary<string, object?> Items { get; } = new Dictionary<string, object?>();
|
||||||
public Dictionary<string, PathGeometry> Items { get; set; } = new Dictionary<string, PathGeometry>();
|
|
||||||
|
|
||||||
public object? Convert(IList<object?> values, Type targetType, object? parameter, CultureInfo culture)
|
public object? Convert(IList<object?> values, Type targetType, object? parameter, CultureInfo culture)
|
||||||
{
|
{
|
||||||
@@ -21,8 +19,10 @@ public class FileIconConverter: IMultiValueConverter
|
|||||||
{
|
{
|
||||||
return Items["file"];
|
return Items["file"];
|
||||||
}
|
}
|
||||||
|
|
||||||
return isOpen ? Items["folderOpen"] : Items["folderClosed"];
|
return isOpen ? Items["folderOpen"] : Items["folderClosed"];
|
||||||
}
|
}
|
||||||
|
|
||||||
return AvaloniaProperty.UnsetValue;
|
return AvaloniaProperty.UnsetValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -13,9 +13,9 @@
|
|||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
<Window.Resources>
|
<Window.Resources>
|
||||||
<converters:FileIconConverter x:Key="FileIconConverter">
|
<converters:FileIconConverter x:Key="FileIconConverter">
|
||||||
<PathGeometry x:Key="file">M14,2H6A2,2 0 0,0 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2M18,20H6V4H13V9H18V20Z</PathGeometry>
|
<StaticResource x:Key="file" ResourceKey="SemiIconFile" />
|
||||||
<PathGeometry x:Key="folderOpen">M6.1,10L4,18V8H21A2,2 0 0,0 19,6H12L10,4H4A2,2 0 0,0 2,6V18A2,2 0 0,0 4,20H19C19.9,20 20.7,19.4 20.9,18.5L23.2,10H6.1M19,18H6L7.6,12H20.6L19,18Z</PathGeometry>
|
<StaticResource x:Key="folderOpen" ResourceKey="SemiIconFolderOpen" />
|
||||||
<PathGeometry x:Key="folderClosed">M20,18H4V8H20M20,6H12L10,4H4C2.89,4 2,4.89 2,6V18A2,2 0 0,0 4,20H20A2,2 0 0,0 22,18V8C22,6.89 21.1,6 20,6Z</PathGeometry>
|
<StaticResource x:Key="folderClosed" ResourceKey="SemiIconFolder" />
|
||||||
</converters:FileIconConverter>
|
</converters:FileIconConverter>
|
||||||
</Window.Resources>
|
</Window.Resources>
|
||||||
<Grid RowDefinitions="Auto, *">
|
<Grid RowDefinitions="Auto, *">
|
||||||
@@ -58,7 +58,7 @@
|
|||||||
</TreeDataGrid.Resources>
|
</TreeDataGrid.Resources>
|
||||||
<TreeDataGrid.Styles>
|
<TreeDataGrid.Styles>
|
||||||
<Style Selector="TreeDataGrid TreeDataGridRow:nth-last-child(2n)">
|
<Style Selector="TreeDataGrid TreeDataGridRow:nth-last-child(2n)">
|
||||||
<Setter Property="Background" Value="#20808080" />
|
<Setter Property="Background" Value="{DynamicResource SemiColorFill0}" />
|
||||||
</Style>
|
</Style>
|
||||||
</TreeDataGrid.Styles>
|
</TreeDataGrid.Styles>
|
||||||
</TreeDataGrid>
|
</TreeDataGrid>
|
||||||
@@ -86,10 +86,8 @@
|
|||||||
<DataTemplate x:Key="FileNameCell" DataType="vm:FileNodeViewModel">
|
<DataTemplate x:Key="FileNameCell" DataType="vm:FileNodeViewModel">
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<PathIcon
|
<PathIcon
|
||||||
Width="16"
|
Theme="{StaticResource InnerPathIcon}"
|
||||||
Height="16"
|
Margin="8,0">
|
||||||
Margin="8,0"
|
|
||||||
VerticalAlignment="Center">
|
|
||||||
<PathIcon.Data>
|
<PathIcon.Data>
|
||||||
<MultiBinding Converter="{StaticResource FileIconConverter}">
|
<MultiBinding Converter="{StaticResource FileIconConverter}">
|
||||||
<Binding Path="IsDirectory" />
|
<Binding Path="IsDirectory" />
|
||||||
@@ -127,7 +125,7 @@
|
|||||||
</TreeDataGrid.Resources>
|
</TreeDataGrid.Resources>
|
||||||
<TreeDataGrid.Styles>
|
<TreeDataGrid.Styles>
|
||||||
<Style Selector="TreeDataGrid TreeDataGridRow:nth-child(2n)">
|
<Style Selector="TreeDataGrid TreeDataGridRow:nth-child(2n)">
|
||||||
<Setter Property="Background" Value="#20808080" />
|
<Setter Property="Background" Value="{DynamicResource SemiColorFill0}" />
|
||||||
</Style>
|
</Style>
|
||||||
</TreeDataGrid.Styles>
|
</TreeDataGrid.Styles>
|
||||||
</TreeDataGrid>
|
</TreeDataGrid>
|
||||||
@@ -135,4 +133,4 @@
|
|||||||
</TabItem>
|
</TabItem>
|
||||||
</TabControl>
|
</TabControl>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
Reference in New Issue
Block a user