/// <summary>
 /// Updates all property values in the PropertyGrid with the data from the SelectedObject
 /// </summary>
 public void Update()
 {
     foreach (var item in Properties)
     {
         BindingOperations.GetBindingExpressionBase(item, PropertyItem.ValueProperty).UpdateTarget();
     }
 }
        private static void OnValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ComparisonValue       comparisonValue       = (ComparisonValue)d;
            BindingExpressionBase bindingExpressionBase = BindingOperations.GetBindingExpressionBase(comparisonValue, BindingToTriggerProperty);

            bindingExpressionBase?.UpdateSource();
        }
Example #3
0
        static void OnSelectedColorChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
        {
            StandardColorPicker thisControl = obj as StandardColorPicker;

            if (thisControl == null)
            {
                return;
            }

            Color newSelectedColor = (Color)e.NewValue;

            if (thisControl.FindStandardColor(newSelectedColor) == -1)
            {
                thisControl.StandardColors[thisControl.StandardColors.Length - 1] = newSelectedColor;
            }

            thisControl.comboBoxStandardColor.SelectedValue = newSelectedColor;

            if (e.NewValue != null && thisControl.IsLoaded)
            {
                BindingExpressionBase expr = BindingOperations.GetBindingExpressionBase(thisControl, StandardColorPicker.CommandParameterProperty);
                if (expr != null)
                {
                    expr.UpdateTarget();
                }

                if (thisControl.Command != null && thisControl.Command.CanExecute(thisControl.CommandParameter))
                {
                    thisControl.Command.Execute(thisControl.CommandParameter);
                }
            }
        }
Example #4
0
        private static void BrowseFolderExecute(Window window, ExecutedRoutedEventArgs e)
        {
            var tb = (TextBox)e.OriginalSource;

            if (!tb.AcceptsReturn)
            {
                var path = e.Parameter as string ?? tb.GetValue(TextBox.TextProperty) as string;
                while (!string.IsNullOrEmpty(path) && !Directory.Exists(path))
                {
                    try {
                        path = Path.GetDirectoryName(path);
                    } catch (ArgumentException) {
                        path = null; // path was in incorrect format, continue with default (current) directory
                    }
                }
                path = Dialogs.BrowseForDirectory(
                    window == null ? IntPtr.Zero : new WindowInteropHelper(window).Handle,
                    path
                    );
                if (path != null)
                {
                    tb.SetCurrentValue(TextBox.TextProperty, path);
                    var binding = BindingOperations.GetBindingExpressionBase(tb, TextBox.TextProperty);
                    if (binding != null)
                    {
                        binding.UpdateSource();
                    }
                }
            }
            else
            {
                var existing = tb.GetValue(TextBox.TextProperty) as string;
                var path     = e.Parameter as string;
                while (!string.IsNullOrEmpty(path) && !Directory.Exists(path))
                {
                    path = Path.GetDirectoryName(path);
                }
                path = Dialogs.BrowseForDirectory(
                    window == null ? IntPtr.Zero : new WindowInteropHelper(window).Handle,
                    path
                    );
                if (path != null)
                {
                    if (string.IsNullOrEmpty(existing))
                    {
                        tb.SetCurrentValue(TextBox.TextProperty, path);
                    }
                    else
                    {
                        tb.SetCurrentValue(TextBox.TextProperty, existing.TrimEnd(new[] { '\r', '\n' }) + Environment.NewLine + path);
                    }
                    var binding = BindingOperations.GetBindingExpressionBase(tb, TextBox.TextProperty);
                    if (binding != null)
                    {
                        binding.UpdateSource();
                    }
                }
            }
        }
        internal void UpdateAdvanceOptionsForItem(MarkupObject markupObject, DependencyObject dependencyObject, DependencyPropertyDescriptor dpDescriptor,
                                                  out object tooltip)
        {
            tooltip = StringConstants.AdvancedProperties;

            bool isResource        = false;
            bool isDynamicResource = false;

            var markupProperty = markupObject.Properties.FirstOrDefault(p => p.Name == PropertyName);

            if (markupProperty != null)
            {
                //TODO: need to find a better way to determine if a StaticResource has been applied to any property not just a style(maybe with StaticResourceExtension)
                isResource        = typeof(Style).IsAssignableFrom(markupProperty.PropertyType);
                isDynamicResource = typeof(DynamicResourceExtension).IsAssignableFrom(markupProperty.PropertyType);
            }

            if (isResource || isDynamicResource)
            {
                tooltip = StringConstants.Resource;
            }
            else
            {
                if ((dependencyObject != null) && (dpDescriptor != null))
                {
                    if (BindingOperations.GetBindingExpressionBase(dependencyObject, dpDescriptor.DependencyProperty) != null)
                    {
                        tooltip = StringConstants.Databinding;
                    }
                    else
                    {
                        BaseValueSource bvs =
                            DependencyPropertyHelper
                            .GetValueSource(dependencyObject, dpDescriptor.DependencyProperty)
                            .BaseValueSource;

                        switch (bvs)
                        {
                        case BaseValueSource.Inherited:
                        case BaseValueSource.DefaultStyle:
                        case BaseValueSource.ImplicitStyleReference:
                            tooltip = StringConstants.Inheritance;
                            break;

                        case BaseValueSource.DefaultStyleTrigger:
                            break;

                        case BaseValueSource.Style:
                            tooltip = StringConstants.StyleSetter;
                            break;

                        case BaseValueSource.Local:
                            tooltip = StringConstants.Local;
                            break;
                        }
                    }
                }
            }
        }
Example #6
0
 private void UserPathBoxKeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Return)
     {
         var bindingExpression = BindingOperations.GetBindingExpressionBase(userPathBox, TextBox.TextProperty);
         bindingExpression.UpdateSource();
     }
 }
Example #7
0
        public void AddPlaceHolder()
        {
            AddLabel("Place Holder");

            var binding = new Binding("PlaceholderKey");

            var grid = new Grid();

            grid.RowDefinitions.Add(new RowDefinition());
            grid.ColumnDefinitions.Add(new ColumnDefinition());
            grid.ColumnDefinitions.Add(new ColumnDefinition
            {
                Width = GridLength.Auto
            });

            var textBox = new TextBox();

            textBox.SetBinding(TextBox.TextProperty, binding);
            textBox.VerticalAlignment = VerticalAlignment.Center;
            grid.Children.Add(textBox);
            textBox.SetValue(Grid.ColumnProperty, 0);

            var button = new Button
            {
                Content = "Browse",
                Width   = 75,
                Height  = 23,
                Margin  = new Thickness(2, 0, 0, 0)
            };

            button.Click += delegate
            {
                var container = RenderingItem.RenderingContainer;
                if (container == null)
                {
                    return;
                }

                var key = RenderingItem.PlaceholderKey.ToString();

                var dialog = new PlaceholderDialog();
                dialog.Initialize(Resources.Browse, key, container);
                if (AppHost.Shell.ShowDialog(dialog) != true)
                {
                    return;
                }

                RenderingItem.PlaceholderKey = new PlaceHolderKey(dialog.SelectedValue);
                UpdateTarget();
            };

            grid.Children.Add(button);
            button.SetValue(Grid.ColumnProperty, 1);

            Grid.Children.Add(grid);

            bindings.Add(BindingOperations.GetBindingExpressionBase(textBox, TextBox.TextProperty));
        }
        private void Update()
        {
            if (this.ignoreUpdate)
            {
                return;
            }

            this.isLocallySet     = false;
            this.isInvalidBinding = false;
            this.bindingError     = string.Empty;
            this.isDatabound      = false;

            var dp = this.DependencyProperty;
            var d  = this.Target as DependencyObject;

            if (SnoopModes.MultipleDispatcherMode &&
                d != null &&
                d.Dispatcher != this.Dispatcher)
            {
                return;
            }

            if (dp != null &&
                d != null)
            {
                //Debugger.Launch();
                if (d.ReadLocalValue(dp) != DependencyProperty.UnsetValue)
                {
                    this.isLocallySet = true;
                }

                var expression = BindingOperations.GetBindingExpressionBase(d, dp);
                if (expression != null)
                {
                    this.isDatabound = true;

                    if (expression.HasError ||
                        (expression.Status != BindingStatus.Active && !(expression is PriorityBindingExpression)))
                    {
                        this.isInvalidBinding = true;
                    }
                }

                this.valueSource = DependencyPropertyHelper.GetValueSource(d, dp);
            }

            this.OnPropertyChanged(nameof(this.IsLocallySet));
            this.OnPropertyChanged(nameof(this.IsInvalidBinding));
            this.OnPropertyChanged(nameof(this.BindingError));
            this.OnPropertyChanged(nameof(this.StringValue));
            this.OnPropertyChanged(nameof(this.ResourceKey));
            this.OnPropertyChanged(nameof(this.DescriptiveValue));
            this.OnPropertyChanged(nameof(this.IsDatabound));
            this.OnPropertyChanged(nameof(this.IsExpression));
            this.OnPropertyChanged(nameof(this.IsAnimated));
            this.OnPropertyChanged(nameof(this.ValueSource));
        }
Example #9
0
 private void NotifyPropertyChange(string propname)
 {
     switch (propname.ToLower())
     {
     case "IsOpen":
         BindingOperations.GetBindingExpressionBase(popup, Popup.IsOpenProperty).UpdateTarget();
         break;
     }
 }
Example #10
0
        /// <summary>
        /// Updates the target of the specified bound property.
        /// </summary>
        /// <param name="o">The o.</param>
        /// <param name="prop">The prop.</param>
        public static void UpdateTarget(this DependencyObject o, DependencyProperty prop)
        {
            var exp = BindingOperations.GetBindingExpressionBase(o, prop);

            if (exp != null)
            {
                exp.UpdateTarget();
            }
        }
        /// <summary>
        /// Updates the source according to the specified property.
        /// </summary>
        /// <param name="o">The source.</param>
        /// <param name="prop">The property.</param>
        public static void UpdateSourceProperty(this DependencyObject o, DependencyProperty prop)
        {
            BindingExpressionBase exp = BindingOperations.GetBindingExpressionBase(o, prop);

            if (exp != null)
            {
                exp.UpdateSource();
            }
        }
Example #12
0
        protected virtual void ResetValue()
        {
            var binding = BindingOperations.GetBindingExpressionBase(this, DescriptorPropertyDefinition.ValueProperty);

            if (binding != null)
            {
                binding.UpdateTarget();
            }
        }
Example #13
0
        internal void UpdateValueFromSource()
        {
            var bindingExpr = BindingOperations.GetBindingExpressionBase(this, DescriptorPropertyDefinitionBase.ValueProperty);

            if (bindingExpr != null)
            {
                bindingExpr.UpdateTarget();
            }
        }
        public void UpdateBindingError()
        {
            if (this.IsDatabound == false ||
                this.IsInvalidBinding == false)
            {
                return;
            }

            var dp = this.DependencyProperty;
            var d  = this.Target as DependencyObject;

            if (SnoopModes.MultipleDispatcherMode &&
                d != null &&
                d.Dispatcher != this.Dispatcher)
            {
                return;
            }

            if (dp is null ||
                d is null)
            {
                return;
            }

            var expression = BindingOperations.GetBindingExpressionBase(d, dp);

            if (expression is null)
            {
                return;
            }

            var builder     = new StringBuilder();
            var writer      = new StringWriter(builder);
            var tracer      = new TextWriterTraceListener(writer);
            var levelBefore = PresentationTraceSources.DataBindingSource.Switch.Level;

            PresentationTraceSources.DataBindingSource.Switch.Level = SourceLevels.All;
            PresentationTraceSources.DataBindingSource.Listeners.Add(tracer);

            // reset binding to get the error message.
            this.ignoreUpdate = true;
            d.ClearValue(dp);
            BindingOperations.SetBinding(d, dp, expression.ParentBindingBase);
            this.ignoreUpdate = false;

            // this needs to happen on idle so that we can actually run the binding, which may occur asynchronously.
            this.RunInDispatcherAsync(
                () =>
            {
                this.bindingError = builder.ToString();
                this.OnPropertyChanged(nameof(this.BindingError));
                PresentationTraceSources.DataBindingSource.Listeners.Remove(tracer);
                writer.Close();
                PresentationTraceSources.DataBindingSource.Switch.Level = levelBefore;
            }, DispatcherPriority.ApplicationIdle);
        }
Example #15
0
 protected override void OnKeyDown(KeyEventArgs e)
 {
     if (e.Key == Key.Return)
     {
         var expression = BindingOperations.GetBindingExpressionBase(this, TextProperty);
         expression?.UpdateSource();
         e.Handled = true;
     }
     base.OnKeyDown(e);
 }
Example #16
0
        private static void DoBindingUpdate(DependencyObject dependencyObject, DependencyProperty dependencyProperty)
        {
            BindingExpressionBase bindingBase =
                BindingOperations.GetBindingExpressionBase(dependencyObject, dependencyProperty);

            if (bindingBase != null)
            {
                bindingBase.UpdateTarget();
            }
        }
Example #17
0
        private static void BrowseFolderExecute(Window window, ExecutedRoutedEventArgs e)
        {
            var tb = (TextBox)e.OriginalSource;

            if (!tb.AcceptsReturn)
            {
                var path = e.Parameter as string ?? tb.GetValue(TextBox.TextProperty) as string;
                while (!string.IsNullOrEmpty(path) && !Directory.Exists(path))
                {
                    path = Path.GetDirectoryName(path);
                }
                path = Dialogs.BrowseForDirectory(
                    window == null ? IntPtr.Zero : new WindowInteropHelper(window).Handle,
                    path
                    );
                if (path != null)
                {
                    tb.SetCurrentValue(TextBox.TextProperty, path);
                    var binding = BindingOperations.GetBindingExpressionBase(tb, TextBox.TextProperty);
                    if (binding != null)
                    {
                        binding.UpdateSource();
                    }
                }
            }
            else
            {
                var existing = tb.GetValue(TextBox.TextProperty) as string;
                var path     = e.Parameter as string;
                while (!string.IsNullOrEmpty(path) && !Directory.Exists(path))
                {
                    path = Path.GetDirectoryName(path);
                }
                path = Dialogs.BrowseForDirectory(
                    window == null ? IntPtr.Zero : new WindowInteropHelper(window).Handle,
                    path
                    );
                if (path != null)
                {
                    if (string.IsNullOrEmpty(existing))
                    {
                        tb.SetCurrentValue(TextBox.TextProperty, path);
                    }
                    else
                    {
                        tb.SetCurrentValue(TextBox.TextProperty, existing.TrimEnd(CharExtensions.LineBreakChars) + Environment.NewLine + path);
                    }
                    var binding = BindingOperations.GetBindingExpressionBase(tb, TextBox.TextProperty);
                    if (binding != null)
                    {
                        binding.UpdateSource();
                    }
                }
            }
        }
Example #18
0
        public void AddDataSource()
        {
            AddLabel("DataSource");

            var binding = new Binding("DataSource");

            var grid = new Grid();

            grid.RowDefinitions.Add(new RowDefinition());
            grid.ColumnDefinitions.Add(new ColumnDefinition());
            grid.ColumnDefinitions.Add(new ColumnDefinition
            {
                Width = GridLength.Auto
            });

            var textBox = new TextBox();

            textBox.SetBinding(TextBox.TextProperty, binding);
            textBox.VerticalAlignment = VerticalAlignment.Center;
            grid.Children.Add(textBox);
            textBox.SetValue(Grid.ColumnProperty, 0);

            var button = new Button
            {
                Content = "Browse",
                Width   = 75,
                Height  = 23,
                Margin  = new Thickness(2, 0, 0, 0)
            };

            button.Click += delegate
            {
                var container = RenderingItem.RenderingContainer;
                if (container == null)
                {
                    return;
                }

                var dialog = new SelectItemDialog();
                dialog.Initialize("Data Source", RenderingItem.ItemUri.DatabaseUri, RenderingItem.DataSource ?? string.Empty);
                if (AppHost.Shell.ShowDialog(dialog) != true)
                {
                    return;
                }

                textBox.Text = dialog.SelectedItemUri.ItemId.ToString();
            };

            grid.Children.Add(button);
            button.SetValue(Grid.ColumnProperty, 1);

            Grid.Children.Add(grid);

            bindings.Add(BindingOperations.GetBindingExpressionBase(textBox, TextBox.TextProperty));
        }
Example #19
0
        private void Refresh()
        {
            _savePath = _config.SavePath;
            if (string.IsNullOrEmpty(_config.SavePath))
            {
                _savePath = ConstHelper.DefaultSavePath;
            }
            else
            {
                _savePath += @"\";
            }
            if (!Directory.Exists(_savePath))
            {
                Directory.CreateDirectory(_savePath);
            }

            _processes = Process.GetProcesses().Where(r => r.MainWindowHandle != IntPtr.Zero)
                         .Select(r => new KeyValuePair <string, Process>(r.ProcessName, r))
                         .OrderBy(r => r.Key).ToArray();
            comboProcess.ItemsSource       = _processes;
            comboProcess.DisplayMemberPath = "Key";
            comboProcess.SelectedValuePath = "Value";

            var labels = ObjectExtensions.FindChildren <Label>(this);

            foreach (var label in labels)
            {
                BindingOperations.GetBindingExpressionBase(label, ContentProperty).UpdateTarget();
            }
            var buttons = ObjectExtensions.FindChildren <Button>(this);

            foreach (var button in buttons)
            {
                if (button.Equals(btnSetting) || button.Content == null || !(button.Content is string))
                {
                    continue;
                }

                BindingOperations.GetBindingExpressionBase(button, ContentProperty).UpdateTarget();
            }
            var checkBoxs = ObjectExtensions.FindChildren <CheckBox>(this);

            foreach (var checkBox in checkBoxs)
            {
                if (checkBox.Content == null || !(checkBox.Content is string))
                {
                    continue;
                }

                BindingOperations.GetBindingExpressionBase(checkBox, ContentProperty).UpdateTarget();
            }
            BindingOperations.GetBindingExpressionBase(this, TitleProperty).UpdateTarget();

            Clear();
        }
            /// <summary>
            /// DragEnd event handler from DragDrop behavior.
            /// </summary>
            private void SourceDoDragDrop(ITextSelection selection, IDataObject dataObject)
            {
                // Run OLE drag-drop process. It will eat all user input until the drop
                DragDropEffects allowedDragDropEffects = DragDropEffects.Copy;

                if (!_textEditor.IsReadOnly)
                {
                    allowedDragDropEffects |= DragDropEffects.Move;
                }

                DragDropEffects resultingDragDropEffects = DragDrop.DoDragDrop( //
                    _textEditor.UiScope,                                        // dragSource,
                    dataObject,                                                 //
                    allowedDragDropEffects);

                // Remove source selection
                if (!_textEditor.IsReadOnly &&                          //
                    resultingDragDropEffects == DragDropEffects.Move && //
                    _dragSourceTextRange != null &&
                    !_dragSourceTextRange.IsEmpty)
                {
                    // Normally we delete the source selection from OnDrop event,
                    // unless source and target TextBoxes are different.
                    // In this case the source selection is still not empty,
                    // which means that target was in a different TextBox.
                    // So we still need to delete the selected content in the source one.
                    // This will create an undo unit different from a dropping one,
                    // which is ok, because it will be in different TextBox's undo stack.
                    using (selection.DeclareChangeBlock())
                    {
                        // This is end of Move - we need to delete source content
                        _dragSourceTextRange.Text = String.Empty;
                    }
                }

                // Clean up the text range.
                _dragSourceTextRange = null;

                // Check the data binding expression and update the source and target if the drag source
                // has the binding expression. Without this, data binding is broken after complete the
                // drag-drop operation because Drop() paste the object then set the focus to the target.
                // The losting focus invoke the data binding expression's Update(), but the source isn't
                // updated yet before complete DoDragDrop.
                if (!_textEditor.IsReadOnly)
                {
                    BindingExpressionBase bindingExpression = BindingOperations.GetBindingExpressionBase(
                        _textEditor.UiScope, TextBox.TextProperty);
                    if (bindingExpression != null)
                    {
                        bindingExpression.UpdateSource();
                        bindingExpression.UpdateTarget();
                    }
                }
            }
Example #21
0
        public void AddFileProperty([NotNull] string text, [NotNull] string propertyName)
        {
            Assert.ArgumentNotNull(text, nameof(text));
            Assert.ArgumentNotNull(propertyName, nameof(propertyName));

            AddLabel(text);

            var property = GetProperty(propertyName);
            var binding  = new Binding(property.Name);

            var grid = new Grid();

            grid.RowDefinitions.Add(new RowDefinition());
            grid.ColumnDefinitions.Add(new ColumnDefinition());
            grid.ColumnDefinitions.Add(new ColumnDefinition
            {
                Width = GridLength.Auto
            });

            var textBox = new TextBox();

            textBox.SetBinding(TextBox.TextProperty, binding);
            textBox.VerticalAlignment = VerticalAlignment.Center;
            grid.Children.Add(textBox);
            textBox.SetValue(Grid.ColumnProperty, 0);

            var button = new Button
            {
                Content = "Browse",
                Width   = 75,
                Height  = 23,
                Margin  = new Thickness(2, 0, 0, 0)
            };

            button.Click += delegate
            {
                var dialog = new SelectFileDialog
                {
                    Site = RenderingItem.ItemUri.Site
                };

                if (dialog.ShowDialog())
                {
                    textBox.Text = dialog.SelectedFilePath.Replace("\\", "/");
                }
            };

            grid.Children.Add(button);
            button.SetValue(Grid.ColumnProperty, 1);

            Grid.Children.Add(grid);

            bindings.Add(BindingOperations.GetBindingExpressionBase(textBox, TextBox.TextProperty));
        }
Example #22
0
        public void UpdateBindingExpression()
        {
            var be = BindingOperations.GetBindingExpressionBase(ValueLabel, ContentControl.ContentProperty);

            if (be != null)
            {
                be.UpdateTarget();
                this.UpdateLayout();
                be.UpdateTarget();
            }
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            DinerMax3000.WPFClient.DinerMax3000ViewModel currentViewModel =
                (DinerMax3000.WPFClient.DinerMax3000ViewModel)DataContext;

            DinerMax3000.Business.MenuItem newMenuItem = currentViewModel.NewMenuItem;

            currentViewModel.SelectedMenu.SaveNewMenuItem(newMenuItem.Title, newMenuItem.Description, newMenuItem.Price);

            BindingOperations.GetBindingExpressionBase(cboAllMenus, ComboBox.ItemsSourceProperty).UpdateTarget();
        }
Example #24
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            DinerMax3000ViewModel currentViewModel = (DinerMax3000ViewModel)DataContext;

            foreach (var currentMenuItem in currentViewModel.NewMenuItems)
            {
                currentViewModel.SelectedMenu.SaveNewMenuItem(currentMenuItem.Title, currentMenuItem.Description, currentMenuItem.Price);
            }

            BindingOperations.GetBindingExpressionBase(cboAllMenus, ComboBox.ItemsSourceProperty).UpdateTarget();
        }
Example #25
0
        private void AssociatedObjectOnLostFocus(object sender, RoutedEventArgs routedEventArgs)
        {
            TextBox tb = sender as TextBox;

            //tb.Text = ProperValue;
            tb.Dispatcher.BeginInvoke(new Action(() =>
            {
                var be = BindingOperations.GetBindingExpressionBase(tb, TextBox.TextProperty);
                be.UpdateTarget();
                //tb.ToolTip = e.Error.ErrorContent.ToString();
            }), System.Windows.Threading.DispatcherPriority.Render);
        }
Example #26
0
 protected override void OnKeyDown(KeyEventArgs e)
 {
     if (e.Key == Key.Enter)
     {
         var b = BindingOperations.GetBindingExpressionBase(this, TextProperty);
         if (b != null)
         {
             b.UpdateTarget();
         }
         SelectAll();
     }
 }
Example #27
0
        /// <summary>
        ///     Updates the target of the specified bound property.
        /// </summary>
        /// <param name="o">The o.</param>
        /// <param name="prop">The prop.</param>
        public static void UpdateTarget(this DependencyObject o, DependencyProperty prop)
        {
            ArgumentValidator.NotNull(o, "o");
            ArgumentValidator.NotNull(prop, "prop");

            BindingExpressionBase exp = BindingOperations.GetBindingExpressionBase(o, prop);

            if (exp != null)
            {
                exp.UpdateTarget();
            }
        }
Example #28
0
 /// <inheritdoc/>
 protected override void OnKeyDown(KeyEventArgs e)
 {
     if (e.Key == Key.Enter)
     {
         BindingOperations.GetBindingExpressionBase(this, TextProperty).UpdateSource();
         SelectAll();
     }
     else if (e.Key == Key.Escape)
     {
         BindingOperations.GetBindingExpression(this, TextProperty).UpdateTarget();
     }
 }
Example #29
0
 internal void SetContentInternal(string value)
 {
     if (BindingOperations.GetBindingExpressionBase(this, ContentControl.ContentProperty) != null)
     {
         Content = value;
     }
     else
     {
         this._shouldCoerceContent = true;
         this._coercedContent      = value;
         this.CoerceValue(ContentControl.ContentProperty);
     }
 }
Example #30
0
 protected override void OnKeyDown(KeyEventArgs e)
 {
     if (e.Key == Key.Return)
     {
         BindingExpressionBase expression = BindingOperations.GetBindingExpressionBase(this, EditTextBox.TextProperty);
         if (expression != null)
         {
             expression.UpdateSource();
         }
         e.Handled = true;
     }
     base.OnKeyDown(e);
 }