When I'm attemping to utilize data binding, but local:SessionConverter isn't being recognize and I'm not understanding how to work around it as I'm unable to set the DataContext in the main window due to the parameters.
public enum Data{ Data1, Data2, Data3}public partial class MainWindow : Window{ private readonly ICustomWrapper _customWrapper; public MainWindow(ICustomWrapper customWrapper) { InitializeComponent(); } private Data _data; public Data data { get=> _data; set { _data = value; MessageBox.Show("The selected datum is: " + "value.ToString());} public class SessionConverter : IValueConverter{ public object? Convert(object value, Type targetType, object parameter, CultureInfo culture) { return value?.Equals(parameter); } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { return value?.Equals(true) == true ? parameter : Binding.DoNothing; }}
public enum Data{ Data1, Data2, Data3}public partial class MainWindow : Window{ private readonly ICustomWrapper _customWrapper; public MainWindow(ICustomWrapper customWrapper) { InitializeComponent(); } private Data _data; public Data data { get=> _data; set { _data = value; MessageBox.Show("The selected datum is: " + "value.ToString());} public class SessionConverter : IValueConverter{ public object? Convert(object value, Type targetType, object parameter, CultureInfo culture) { return value?.Equals(parameter); } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { return value?.Equals(true) == true ? parameter : Binding.DoNothing; }}
The .xaml code looks like the following (button data removed)