Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
        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));
                    }
                }
            }
        }