public OptionsPage(OptionPageGrid optionPageGrid) { InitializeComponent(); DataContext = optionPageGrid; foreach (var textBox in this.FindChildren <TextBox>()) { textBox.GotKeyboardFocus += Control_GotKeyboardFocus; textBox.LostKeyboardFocus += TextBox_LostKeyboardFocus; } foreach (var comboBox in this.FindChildren <ComboBox>()) { comboBox.GotKeyboardFocus += Control_GotKeyboardFocus; comboBox.LostKeyboardFocus += ComboBox_LostKeyboardFocus; } foreach (var textBox in grpPersistence.FindChildren <TextBox>()) { var bindingPath = (textBox).GetBindingExpression(TextBox.TextProperty)?.ParentBinding?.Path?.Path; if (bindingPath != null) { TextBoxIsValidTaskCancelSources.Add(textBox, new CancellationTokenSource()); textBox.LostKeyboardFocus += PersistencePropertyBoundTextBox_KeyboardLostFocus; textBox.TextChanged += PersistencePropertyBoundTextBox_TextChanged; } } Loaded += OptionsPage_Loaded; }
internal void UpdateFromGrid(OptionPageGrid optionPageGrid) { foreach (var key in SettingsProperties.Keys) { foreach (var prop in SettingsProperties[key]) { var optionProp = OptionPageGridProperties.SingleOrDefault(p => p.Name == prop.Name); if (optionProp != null) { prop.SetValue(key, optionProp.GetValue(optionPageGrid)); } } } }