Skip to content

Commit 27676d4

Browse files
committed
Fix: Fixed FormatException for invalid colors
1 parent b2f66b5 commit 27676d4

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/Files.App/Converters/StringToBrushConverter.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the MIT License. See the LICENSE.
33

44
using CommunityToolkit.WinUI.Helpers;
5+
using Microsoft.UI;
56
using Microsoft.UI.Xaml.Data;
67
using Microsoft.UI.Xaml.Media;
78

@@ -14,7 +15,14 @@ internal sealed class StringToBrushConverter : IValueConverter
1415
if (value is not string strValue)
1516
return null;
1617

17-
return new SolidColorBrush(strValue.ToColor());
18+
try
19+
{
20+
return new SolidColorBrush(strValue.ToColor());
21+
}
22+
catch (FormatException)
23+
{
24+
return new SolidColorBrush(Colors.Transparent);
25+
}
1826
}
1927

2028
public object ConvertBack(object value, Type targetType, object parameter, string language)

0 commit comments

Comments
 (0)