37 lines
1.2 KiB
C#
37 lines
1.2 KiB
C#
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Controls.Primitives;
|
|
|
|
namespace SSPCTester.UI.Views;
|
|
|
|
public partial class SettingsManualView : UserControl
|
|
{
|
|
public SettingsManualView() => InitializeComponent();
|
|
|
|
private void DraftChanged(object sender, RoutedEventArgs e)
|
|
{
|
|
if (!IsLoaded) return;
|
|
UpdateBindingSource(sender);
|
|
if (DataContext is ViewModels.SettingsViewModel vm)
|
|
vm.NotifyDraftChanged();
|
|
}
|
|
|
|
private static void UpdateBindingSource(object sender)
|
|
{
|
|
if (sender is ComboBox comboBox)
|
|
{
|
|
comboBox.GetBindingExpression(Selector.SelectedValueProperty)?.UpdateSource();
|
|
comboBox.GetBindingExpression(Selector.SelectedItemProperty)?.UpdateSource();
|
|
comboBox.GetBindingExpression(ComboBox.TextProperty)?.UpdateSource();
|
|
}
|
|
else if (sender is TextBox textBox)
|
|
{
|
|
textBox.GetBindingExpression(TextBox.TextProperty)?.UpdateSource();
|
|
}
|
|
else if (sender is ToggleButton toggleButton)
|
|
{
|
|
toggleButton.GetBindingExpression(ToggleButton.IsCheckedProperty)?.UpdateSource();
|
|
}
|
|
}
|
|
}
|