Merge pull request #533 from WCKYWCKF/pr1

Feat: add a new control PathPicker, add PathPickerDemo
This commit is contained in:
Dong Bin
2025-01-15 22:04:31 +08:00
committed by GitHub
11 changed files with 626 additions and 18 deletions

View File

@@ -0,0 +1,83 @@
<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}"
Margin="1,0,0,0">
</Button>
<TextBox Name="PART_TextBox"
DockPanel.Dock="Left"
AcceptsReturn="{TemplateBinding AllowMultiple}"
Text="{TemplateBinding SelectedPathsText,Mode=TwoWay}">
</TextBox>
</DockPanel>
</ControlTemplate>
</Setter>
<Style Selector="^[AllowMultiple=False]">
<Style Selector="^ /template/ Button#PART_Button">
<Setter Property="DockPanel.Dock" Value="Right"></Setter>
</Style>
<Style Selector="^ /template/ TextBox#PART_TextBox">
<Setter Property="DockPanel.Dock" Value="Left"></Setter>
</Style>
</Style>
<Style Selector="^[AllowMultiple=True]">
<Style Selector="^ /template/ Button#PART_Button">
<Setter Property="DockPanel.Dock" Value="Top"></Setter>
</Style>
<Style Selector="^ /template/ TextBox#PART_TextBox">
<Setter Property="DockPanel.Dock" Value="Bottom"></Setter>
</Style>
</Style>
</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}">
</Button>
</ControlTemplate>
</Setter>
</ControlTheme>
<ControlTheme x:Key="PathPickerForListView" 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}">
<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>