feat: add warning, resolve a crash issue.
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
x:DataType="vm:EnumSelectorDemoViewModel"
|
x:DataType="vm:EnumSelectorDemoViewModel"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
|
<u:Banner Type="Warning" Header="Native AOT non-compatible" Content="EnumSelector highly relies on reflection, it is not compatible with NativeAOT compilation. " Classes="Warning"></u:Banner>
|
||||||
<ToggleSwitch Name="description" Content="Show Description" />
|
<ToggleSwitch Name="description" Content="Show Description" />
|
||||||
<TextBlock Text="Select Type" />
|
<TextBlock Text="Select Type" />
|
||||||
<ComboBox
|
<ComboBox
|
||||||
|
|||||||
@@ -91,9 +91,12 @@ public class EnumSelector: TemplatedControl
|
|||||||
if (_updateFromComboBox) return;
|
if (_updateFromComboBox) return;
|
||||||
var newValue = args.NewValue.Value;
|
var newValue = args.NewValue.Value;
|
||||||
if (newValue is null)
|
if (newValue is null)
|
||||||
|
{
|
||||||
|
if (Values?.Any() == true)
|
||||||
{
|
{
|
||||||
SetCurrentValue(SelectedValueProperty, null);
|
SetCurrentValue(SelectedValueProperty, null);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (newValue.GetType() != EnumType)
|
if (newValue.GetType() != EnumType)
|
||||||
|
|||||||
Reference in New Issue
Block a user