diff --git a/src/Files.App/ViewModels/Properties/Items/FileProperty.cs b/src/Files.App/ViewModels/Properties/Items/FileProperty.cs index 78d2e3012a90..dc7177d30044 100644 --- a/src/Files.App/ViewModels/Properties/Items/FileProperty.cs +++ b/src/Files.App/ViewModels/Properties/Items/FileProperty.cs @@ -217,7 +217,7 @@ private IValueConverter GetConverter() /// Converts the property to a string to be displayed /// /// - private string ConvertToString() + private string? ConvertToString() { // Don't attempt any convert null values if (Value is null) @@ -227,28 +227,27 @@ private string ConvertToString() if (EnumeratedList is not null) { - var value = ""; - int valueKey; - try { - valueKey = Convert.ToInt32(Value); + return EnumeratedList.TryGetValue(Convert.ToInt32(Value), out var value) ? + value.GetLocalizedResource() : null; } catch { - if (!int.TryParse(Value.ToString(), out valueKey)) - { - return null; - } + return null; } - - return EnumeratedList.TryGetValue(valueKey, out value) ? value.GetLocalizedResource() : null; - } if (DisplayFunction is not null) { - return DisplayFunction.Invoke(Value); + try + { + return DisplayFunction.Invoke(Value); + } + catch + { + return null; + } } if (Converter is not null)