diff --git a/src/modules/imageresizer/ui/App.xaml b/src/modules/imageresizer/ui/App.xaml
index 27b50ccee3..d177d900e6 100644
--- a/src/modules/imageresizer/ui/App.xaml
+++ b/src/modules/imageresizer/ui/App.xaml
@@ -18,6 +18,7 @@
+
\ No newline at end of file
diff --git a/src/modules/imageresizer/ui/Views/EnumToIntConverter.cs b/src/modules/imageresizer/ui/Views/EnumToIntConverter.cs
new file mode 100644
index 0000000000..fcfd151c77
--- /dev/null
+++ b/src/modules/imageresizer/ui/Views/EnumToIntConverter.cs
@@ -0,0 +1,21 @@
+// Copyright (c) Brice Lambson
+// The Brice Lambson licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information. Code forked from Brice Lambson's https://github.com/bricelam/ImageResizer/
+
+using System;
+using System.Globalization;
+using System.Windows;
+using System.Windows.Data;
+
+namespace ImageResizer.Views
+{
+ [ValueConversion(typeof(Enum), typeof(int))]
+ internal class EnumToIntConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ => (int)value;
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ => targetType.GetEnumValues().GetValue((int)value);
+ }
+}
diff --git a/src/modules/imageresizer/ui/Views/EnumValueConverter.cs b/src/modules/imageresizer/ui/Views/EnumValueConverter.cs
index 4eb0abdd25..efe421ff56 100644
--- a/src/modules/imageresizer/ui/Views/EnumValueConverter.cs
+++ b/src/modules/imageresizer/ui/Views/EnumValueConverter.cs
@@ -16,6 +16,11 @@ namespace ImageResizer.Views
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var type = value?.GetType();
+ if (!type.IsEnum)
+ {
+ return value;
+ }
+
var builder = new StringBuilder();
builder
diff --git a/src/modules/imageresizer/ui/Views/InputPage.xaml b/src/modules/imageresizer/ui/Views/InputPage.xaml
index 0b90254fd0..b38879f0ba 100644
--- a/src/modules/imageresizer/ui/Views/InputPage.xaml
+++ b/src/modules/imageresizer/ui/Views/InputPage.xaml
@@ -179,9 +179,9 @@
HorizontalAlignment="Stretch"
AutomationProperties.Name="{x:Static p:Resources.Resize_Type}"
ItemsSource="{Binding ResizeFitValues, Mode=OneWay}"
- SelectedIndex="0">
+ SelectedIndex="{Binding ElementName=SizeComboBox, Path=SelectedValue.Fit, Mode=TwoWay, Converter={StaticResource EnumToIntConverter}}">
-
+
+ SelectedIndex="{Binding ElementName=SizeComboBox, Path=SelectedValue.Unit, Mode=TwoWay, Converter={StaticResource EnumToIntConverter}}">
-
+