fix:should be PathPickerForListView in demo
add:Maybe we can add a command demo here to show how to trigger the bound command. change:I think these two themes should be merged, and the "AcceptReturn" should just be controlled by "AllowMultiple" add:One more thing, we should add a property to control what to do when user cancelled a selection. Sometimes I just want to keep the original selection.
This commit is contained in:
@@ -32,6 +32,10 @@
|
||||
<ToggleButton Name="AllowMultiple" Content="AllowMultiple" u:FormItem.NoLabel="True"
|
||||
HorizontalAlignment="Stretch">
|
||||
</ToggleButton>
|
||||
<ToggleButton Name="IsCancelingPickerAlsoTriggers" Content="Canceling selection also triggers the Command."
|
||||
u:FormItem.NoLabel="True"
|
||||
HorizontalAlignment="Stretch">
|
||||
</ToggleButton>
|
||||
<u:EnumSelector Name="UsePickerType" EnumType="u:UsePickerTypes" u:FormItem.Label="UsePickerType"></u:EnumSelector>
|
||||
</u:Form>
|
||||
</StackPanel>
|
||||
@@ -47,20 +51,9 @@
|
||||
AllowMultiple="{Binding #AllowMultiple.IsChecked}"
|
||||
UsePickerType="{Binding #UsePickerType.Value}"
|
||||
SelectedPathsText="{Binding Path,Mode=OneWayToSource}"
|
||||
SelectedPaths="{Binding Paths,Mode=OneWayToSource}">
|
||||
</u:PathPicker>
|
||||
</HeaderedContentControl>
|
||||
<HeaderedContentControl Header="PathPickerForMultipleText">
|
||||
<u:PathPicker Title="{Binding #Title.Text}"
|
||||
Theme="{DynamicResource PathPickerForMultipleText}"
|
||||
SuggestedFileName="{Binding #SuggestedFileName.Text}"
|
||||
SuggestedStartPath="{Binding #SuggestedStartPath.Text}"
|
||||
FileFilter="{Binding #FileFilter.Text}"
|
||||
DefaultFileExtension="{Binding #DefaultFileExtension.Text}"
|
||||
AllowMultiple="{Binding #AllowMultiple.IsChecked}"
|
||||
UsePickerType="{Binding #UsePickerType.Value}"
|
||||
SelectedPathsText="{Binding Path,Mode=OneWayToSource}"
|
||||
SelectedPaths="{Binding Paths,Mode=OneWayToSource}">
|
||||
SelectedPaths="{Binding Paths,Mode=OneWayToSource}"
|
||||
Command="{Binding SelectedCommand}"
|
||||
IsCancelingPickerAlsoTriggers="{Binding #IsCancelingPickerAlsoTriggers.IsChecked}">
|
||||
</u:PathPicker>
|
||||
</HeaderedContentControl>
|
||||
<HeaderedContentControl Header="PathPickerOnlyButton">
|
||||
@@ -73,11 +66,13 @@
|
||||
AllowMultiple="{Binding #AllowMultiple.IsChecked}"
|
||||
UsePickerType="{Binding #UsePickerType.Value}"
|
||||
SelectedPathsText="{Binding Path,Mode=OneWayToSource}"
|
||||
SelectedPaths="{Binding Paths,Mode=OneWayToSource}">
|
||||
SelectedPaths="{Binding Paths,Mode=OneWayToSource}"
|
||||
Command="{Binding SelectedCommand}"
|
||||
IsCancelingPickerAlsoTriggers="{Binding #IsCancelingPickerAlsoTriggers.IsChecked}">
|
||||
</u:PathPicker>
|
||||
</HeaderedContentControl>
|
||||
<HeaderedContentControl Header="PathPickerForListView">
|
||||
<u:PathPicker Theme="{DynamicResource PathPickerForList}"
|
||||
<u:PathPicker Theme="{DynamicResource PathPickerForListView}"
|
||||
Title="{Binding #Title.Text}"
|
||||
SuggestedFileName="{Binding #SuggestedFileName.Text}"
|
||||
SuggestedStartPath="{Binding #SuggestedStartPath.Text}"
|
||||
@@ -86,13 +81,16 @@
|
||||
AllowMultiple="{Binding #AllowMultiple.IsChecked}"
|
||||
UsePickerType="{Binding #UsePickerType.Value}"
|
||||
SelectedPathsText="{Binding Path,Mode=OneWayToSource}"
|
||||
SelectedPaths="{Binding Paths,Mode=OneWayToSource}">
|
||||
SelectedPaths="{Binding Paths,Mode=OneWayToSource}"
|
||||
Command="{Binding SelectedCommand}"
|
||||
IsCancelingPickerAlsoTriggers="{Binding #IsCancelingPickerAlsoTriggers.IsChecked}">
|
||||
</u:PathPicker>
|
||||
</HeaderedContentControl>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
<ScrollViewer Grid.Column="1" Grid.Row="0" Grid.RowSpan="2">
|
||||
<StackPanel Spacing="1">
|
||||
<TextBlock Text="{Binding CommandTriggerCount,StringFormat='Command Trigger Count:{0}'}"></TextBlock>
|
||||
<HeaderedContentControl Header="SelectedPathsText">
|
||||
<TextBox Name="SelectedPath" u:FormItem.Label="SelectedPath" IsReadOnly="True"
|
||||
Text="{Binding Path}">
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
|
||||
namespace Ursa.Demo.ViewModels;
|
||||
|
||||
@@ -7,4 +8,11 @@ public partial class PathPickerDemoViewModel : ViewModelBase
|
||||
{
|
||||
[ObservableProperty] private string? _path;
|
||||
[ObservableProperty] private IReadOnlyList<string>? _paths;
|
||||
[ObservableProperty] private int _commandTriggerCount = 0;
|
||||
|
||||
[RelayCommand]
|
||||
private void Selected(IReadOnlyList<string> paths)
|
||||
{
|
||||
CommandTriggerCount++;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user