Feat: add a new control PathPicker, add PathPickerDemo

This commit is contained in:
望尘空忧
2025-01-10 11:50:11 +08:00
committed by wckfx
parent dac9656d17
commit 3d08aa37ed
11 changed files with 470 additions and 18 deletions

View File

@@ -0,0 +1,66 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ursa="https://irihi.tech/ursa">
<ControlTheme x:Key="{x:Type ursa:PathPicker}" TargetType="ursa:PathPicker">
<Setter Property="Template">
<ControlTemplate>
<DockPanel HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
VerticalAlignment="{TemplateBinding VerticalAlignment}">
<Button Name="PART_Button"
DockPanel.Dock="Right"
Content="{TemplateBinding Title}"
Command="{TemplateBinding Command}"
Margin="1,0,0,0">
</Button>
<TextBox DockPanel.Dock="Left"
Text="{TemplateBinding SelectedPath,Mode=TwoWay}">
</TextBox>
</DockPanel>
</ControlTemplate>
</Setter>
</ControlTheme>
<ControlTheme x:Key="PathPickerOnlyButton" TargetType="ursa:PathPicker">
<Setter Property="Template">
<ControlTemplate>
<Button Name="PART_Button"
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
VerticalAlignment="{TemplateBinding VerticalAlignment}"
Content="{TemplateBinding Title}"
Command="{TemplateBinding Command}">
</Button>
</ControlTemplate>
</Setter>
</ControlTheme>
<ControlTheme x:Key="PathPickerForList" TargetType="ursa:PathPicker">
<Setter Property="Template">
<ControlTemplate>
<Expander HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
VerticalAlignment="{TemplateBinding VerticalAlignment}">
<Expander.Header>
<Button Name="PART_Button"
HorizontalAlignment="Stretch"
Content="{TemplateBinding Title}"
Command="{TemplateBinding Command}">
<Button.Theme>
<ControlTheme TargetType="Button">
<Setter Property="Template">
<ControlTemplate>
<TextPresenter Text="{TemplateBinding Content}"
Background="Transparent"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch">
</TextPresenter>
</ControlTemplate>
</Setter>
</ControlTheme>
</Button.Theme>
</Button>
</Expander.Header>
<ListBox ItemsSource="{TemplateBinding SelectedPaths}"></ListBox>
</Expander>
</ControlTemplate>
</Setter>
</ControlTheme>
</ResourceDictionary>

View File

@@ -55,5 +55,6 @@
<ResourceInclude Source="UrsaView.axaml" />
<ResourceInclude Source="UrsaWindow.axaml"/>
<ResourceInclude Source="PinCode.axaml" />
<ResourceInclude Source="PathPicker.axaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>