Skip to content

Commit 13aadb6

Browse files
committed
Use Enum.Parse when comparing enum with string.
1 parent 147000a commit 13aadb6

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Microsoft.Toolkit.Uwp.UI/Triggers/IsEqualStateTrigger.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ private static object ConvertToEnum(Type enumType, object value)
9494
{
9595
try
9696
{
97+
if (value is string str)
98+
{
99+
return Enum.Parse(enumType, str);
100+
}
101+
97102
return Enum.IsDefined(enumType, value) ? Enum.ToObject(enumType, value) : null;
98103
}
99104
catch

0 commit comments

Comments
 (0)