feat: add warning, resolve a crash issue.

This commit is contained in:
rabbitism
2024-07-30 01:01:27 +08:00
parent f7dc4d356c
commit cbc17123ae
2 changed files with 5 additions and 1 deletions

View File

@@ -12,6 +12,7 @@
x:DataType="vm:EnumSelectorDemoViewModel"
mc:Ignorable="d">
<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" />
<TextBlock Text="Select Type" />
<ComboBox

View File

@@ -92,7 +92,10 @@ public class EnumSelector: TemplatedControl
var newValue = args.NewValue.Value;
if (newValue is null)
{
SetCurrentValue(SelectedValueProperty, null);
if (Values?.Any() == true)
{
SetCurrentValue(SelectedValueProperty, null);
}
}
else
{