misc: simplify EnumSelectorDemoViewModel.
This commit is contained in:
@@ -26,7 +26,7 @@
|
|||||||
EnumType="{Binding SelectedType}"
|
EnumType="{Binding SelectedType}"
|
||||||
Value="{Binding Value}" />
|
Value="{Binding Value}" />
|
||||||
<TextBlock Text="{Binding Value}" />
|
<TextBlock Text="{Binding Value}" />
|
||||||
<u:Divider Content="Small Size"></u:Divider>
|
<u:Divider Content="Small Size" />
|
||||||
<u:EnumSelector
|
<u:EnumSelector
|
||||||
Width="200"
|
Width="200"
|
||||||
Classes="Small"
|
Classes="Small"
|
||||||
|
|||||||
@@ -11,32 +11,13 @@ using CommunityToolkit.Mvvm.ComponentModel;
|
|||||||
|
|
||||||
namespace Ursa.Demo.ViewModels;
|
namespace Ursa.Demo.ViewModels;
|
||||||
|
|
||||||
public class EnumSelectorDemoViewModel: ObservableObject
|
public partial class EnumSelectorDemoViewModel : ObservableObject
|
||||||
{
|
{
|
||||||
public ObservableCollection<Type?> Types { get; set; }
|
[ObservableProperty] private Type? _selectedType;
|
||||||
|
[ObservableProperty] private object? _value;
|
||||||
|
|
||||||
private Type? _selectedType;
|
public ObservableCollection<Type?> Types { get; set; } =
|
||||||
public Type? SelectedType
|
[
|
||||||
{
|
|
||||||
get => _selectedType;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
SetProperty(ref _selectedType, value);
|
|
||||||
Value = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private object? _value;
|
|
||||||
public object? Value
|
|
||||||
{
|
|
||||||
get => _value;
|
|
||||||
set => SetProperty(ref _value, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public EnumSelectorDemoViewModel()
|
|
||||||
{
|
|
||||||
Types = new ObservableCollection<Type?>()
|
|
||||||
{
|
|
||||||
typeof(HorizontalAlignment),
|
typeof(HorizontalAlignment),
|
||||||
typeof(VerticalAlignment),
|
typeof(VerticalAlignment),
|
||||||
typeof(Orientation),
|
typeof(Orientation),
|
||||||
@@ -51,15 +32,12 @@ public class EnumSelectorDemoViewModel: ObservableObject
|
|||||||
typeof(Key),
|
typeof(Key),
|
||||||
typeof(KeyModifiers),
|
typeof(KeyModifiers),
|
||||||
typeof(RoutingStrategies),
|
typeof(RoutingStrategies),
|
||||||
typeof(CustomEnum),
|
typeof(CustomEnum)
|
||||||
};
|
];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum CustomEnum
|
public enum CustomEnum
|
||||||
{
|
{
|
||||||
[Description("是")]
|
[Description("是")] Yes,
|
||||||
Yes,
|
[Description("否")] No,
|
||||||
[Description("否")]
|
|
||||||
No,
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user