Compare commits

...

2 Commits

Author SHA1 Message Date
3315b758ad Add BoolToStringConverter 2023-05-23 14:10:43 +02:00
4cd1114def Handle closing of ContextWindow correct 2023-05-23 14:09:55 +02:00
2 changed files with 22 additions and 3 deletions

View File

@@ -0,0 +1,19 @@
using System;
using System.Windows.Data;
namespace Elwig.Controls {
public class BoolToValueConverter<T> : IValueConverter {
public T FalseValue { get; set; }
public T TrueValue { get; set; }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
return (bool)value ? TrueValue : FalseValue;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
return value?.Equals(TrueValue) ?? false;
}
}
public class BoolToStringConverter : BoolToValueConverter<string> { }
}

View File

@@ -1,5 +1,5 @@
using Elwig.Helpers;
using System.ComponentModel;
using System;
using System.Windows;
namespace Elwig.Windows {
@@ -11,9 +11,9 @@ namespace Elwig.Windows {
Context = new();
}
protected override void OnClosing(CancelEventArgs evt) {
protected override void OnClosed(EventArgs evt) {
base.OnClosed(evt);
Context.Dispose();
base.OnClosing(evt);
}
}
}