Example #1
1
        public static void SetUpdateBindingOnChange(FrameworkElement element, bool value)
        {
            Action<TextBox, bool> action = (txtBox, updateValue) =>
            {
                if (GetUpdateBindingOnChange(txtBox) == updateValue) return;

                if (updateValue)
                {
                    txtBox.TextChanged += element_TextChanged;
                }
                else
                {
                    txtBox.TextChanged -= element_TextChanged;
                }

                txtBox.SetValue(UpdateBindingOnChangeProperty, updateValue);
            };

            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                if (element is TextBox)
                {
                    action.Invoke(element as TextBox, value);
                    return;
                }

                element.GetChildrens<TextBox>().ForEach(i => action.Invoke(i, value));
            });
        }
Example #2
0
        public static void SetSelectAllOnFocus(FrameworkElement element, bool value)
        {
            Action<TextBox, bool> action = (textBox, value1) =>
            {
                if (GetSelectAllOnFocus(textBox) == value1) return;

                if (value1)
                {
                    textBox.GotFocus += element_GotFocus;
                }
                else
                {
                    textBox.GotFocus -= element_GotFocus;
                }

                textBox.SetValue(SelectAllOnFocusProperty, value1);
            };

            Deployment.Current.Dispatcher.BeginInvoke(() => {
                if (element is TextBox)
                {
                    action.Invoke(element as TextBox, value);
                }
                else
                {
                    element.GetChildrens<TextBox>().ForEach(i => action.Invoke(i, value));
                }
            });
        }