feat: add value validation.
This commit is contained in:
@@ -1,19 +1,30 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d" d:DesignWidth="800"
|
||||
xmlns:vm="clr-namespace:Ursa.Demo.ViewModels;assembly=Ursa.Demo"
|
||||
xmlns:u="https://irihi.tech/ursa"
|
||||
x:DataType="vm:EnumSelectorDemoViewModel"
|
||||
x:CompileBindings="True"
|
||||
d:DesignHeight="450"
|
||||
x:Class="Ursa.Demo.Pages.EnumSelectorDemo">
|
||||
<UserControl
|
||||
x:Class="Ursa.Demo.Pages.EnumSelectorDemo"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:u="https://irihi.tech/ursa"
|
||||
xmlns:vm="clr-namespace:Ursa.Demo.ViewModels;assembly=Ursa.Demo"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
x:CompileBindings="True"
|
||||
x:DataType="vm:EnumSelectorDemoViewModel"
|
||||
mc:Ignorable="d">
|
||||
<StackPanel>
|
||||
<TextBlock Text="Select Type"></TextBlock>
|
||||
<ComboBox ItemsSource="{Binding Types}" DisplayMemberBinding="{Binding Name}" SelectedItem="{Binding SelectedType}"/>
|
||||
<TextBlock Text="Select Value"></TextBlock>
|
||||
<u:EnumSelector EnumType="{Binding SelectedType}" Value="{Binding Value}" />
|
||||
<TextBlock Text="{Binding Value}"></TextBlock>
|
||||
<ToggleSwitch Name="description" Content="Show Description" />
|
||||
<TextBlock Text="Select Type" />
|
||||
<ComboBox
|
||||
Width="200"
|
||||
DisplayMemberBinding="{Binding Name}"
|
||||
ItemsSource="{Binding Types}"
|
||||
SelectedItem="{Binding SelectedType}" />
|
||||
<TextBlock Text="Select Value" />
|
||||
<u:EnumSelector
|
||||
Width="200"
|
||||
DisplayDescription="{Binding #description.IsChecked}"
|
||||
EnumType="{Binding SelectedType}"
|
||||
Value="{Binding Value}" />
|
||||
<TextBlock Text="{Binding Value}" />
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Input;
|
||||
using Avalonia.Animation;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Data;
|
||||
@@ -7,6 +9,7 @@ using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Layout;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
|
||||
namespace Ursa.Demo.ViewModels;
|
||||
|
||||
@@ -50,6 +53,15 @@ public class EnumSelectorDemoViewModel: ObservableObject
|
||||
typeof(Key),
|
||||
typeof(KeyModifiers),
|
||||
typeof(RoutingStrategies),
|
||||
typeof(CustomEnum),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public enum CustomEnum
|
||||
{
|
||||
[Description("是")]
|
||||
Yes,
|
||||
[Description("否")]
|
||||
No,
|
||||
}
|
||||
Reference in New Issue
Block a user