/// <summary> /// Method called when the control content changed. /// </summary> /// <param name="pOldContent">The previous content.</param> /// <param name="pNewContent">The new content.</param> protected override void OnContentChanged(object pOldContent, object pNewContent) { base.OnContentChanged(pOldContent, pNewContent); BindingOperations.ClearAllBindings(this); // The content is the view model. PortViewModel lNewContent = pNewContent as PortViewModel; if (lNewContent != null) { // Stting the content data template. this.ContentTemplate = lNewContent.DataTemplate; // Binding the direction. Binding lDirectionBinding = new Binding("Direction") { Source = lNewContent, Mode = BindingMode.TwoWay }; this.SetBinding(PortView.DirectionProperty, lDirectionBinding); // Binding the tooltip. Binding lTooltipBinding = new Binding("ToolTip") { Source = lNewContent, Mode = BindingMode.TwoWay }; this.SetBinding(PortView.ToolTipProperty, lTooltipBinding); } }
private void Animate(ContentControl currentContentPresenter, ContentControl nextContentPresenter) { var currentExitTransition = ExitTransitionFactory?.Invoke(currentContentPresenter) ?? ExitTransition.Clone(); var currentEnterTransition = EnterTransitionFactory?.Invoke(nextContentPresenter) ?? EnterTransition.Clone(); var exitingContentPresenter = currentContentPresenter; var enteringContentPresenter = nextContentPresenter; if (exitingContentPresenter != null) { void onExitTransitionCompleted(object sender, EventArgs e) { var storyboard = sender as Storyboard; if (storyboard != null) { storyboard.Completed -= onExitTransitionCompleted; } if (currentExitTransition != null) { currentExitTransition.Completed -= onExitTransitionCompleted; } BindingOperations.ClearAllBindings(exitingContentPresenter); _transitionContainer.Children.Remove(exitingContentPresenter); } currentExitTransition.Completed += onExitTransitionCompleted; currentExitTransition.Begin(exitingContentPresenter); } currentEnterTransition.Begin(enteringContentPresenter); }
private void BuildButtonZoomIn(Button button) { if (button == null) { return; } button.Click += (o, e) => { if (gMapControl != null) { gMapControl.Zoom = Math.Min(gMapControl.Zoom + 1.0, gMapControl.MaxZoom); } }; button.Unloaded += (o, e) => { var btn = o as Button; if (btn == null) { return; } BindingOperations.ClearAllBindings(btn); }; }
void rilasciaTuttiBindings() { BindingOperations.ClearAllBindings(rotateTfx); BindingOperations.ClearAllBindings(scaleTfx); BindingOperations.ClearAllBindings(translateTfx); // IL flip non ha proprietà bindate }
/// <summary> /// The comparison for the class /// </summary> /// <param name="x">The object value 1</param> /// <param name="y">The object value 2</param> /// <returns>Returns a number taht determines the order to sort</returns> public int Compare(object x, object y) { if (passFullObjectForComparison) { return(CompareOverride(x, y)); } //get the actual values of the property to compare BindingOperations.ClearAllBindings(this); Binding bindForX = new Binding(SortPropertyName); bindForX.Source = x; BindingOperations.SetBinding(this, ValueForXProperty, bindForX); Binding bindForY = new Binding(SortPropertyName); bindForY.Source = y; BindingOperations.SetBinding(this, ValueForYProperty, bindForY); object valueX = this.GetValue(ValueForXProperty); object valueY = this.GetValue(ValueForYProperty); return(CompareOverride(valueX, valueY)); }
protected override void OnClosed(EventArgs e) { base.OnClosed(e); (cmBCurrentConnection.SelectedItem as ConnectionData)?.Save(); BindingOperations.ClearAllBindings(cmBCurrentConnection); BindingOperations.ClearAllBindings(cmBFilter); BindingOperations.ClearAllBindings(cmBFolder); BindingOperations.ClearAllBindings(lstVwFolders); cmBFilter.Items.DetachFromSourceCollection(); cmBCurrentConnection.Items.DetachFromSourceCollection(); cmBFolder.Items.DetachFromSourceCollection(); lstVwFolders.Items.DetachFromSourceCollection(); cmBFilter.DataContext = null; cmBCurrentConnection.DataContext = null; cmBFolder.DataContext = null; cmBFilter.ItemsSource = null; cmBCurrentConnection.ItemsSource = null; cmBFolder.ItemsSource = null; lstVwFolders.ItemsSource = null; }
private void UpdateCustomGrippers() { if (_CustomGripperCompanion != null) { _CustomGripperCompanion.OnClearCustomElements(_CustomGrippers, _ForegroundElements); _CustomGripperCompanion = null; } foreach (var gripper in _CustomGrippers) { BindingOperations.ClearAllBindings(gripper); } _CustomGrippers.Clear(); foreach (var foregroundElement in _ForegroundElements) { RemoveForgroundElement(foregroundElement); } _ForegroundElements.Clear(); if (SelectedCompanions.Count == 1) { _CustomGripperCompanion = SelectedCompanions[0]; _CustomGripperCompanion.OnCreateCustomElements(_CustomGrippers, _ForegroundElements); foreach (var foregroundElement in _ForegroundElements) { AddForgroundElement(foregroundElement); } } }
private void MappedTypePropertyChanged() { OnPropertyChanged(nameof(MappedType)); //set relevant value control binding BindingOperations.ClearAllBindings(xVariablesComboBox); BindingOperations.ClearAllBindings(xOptionalValuesComboBox); BindingOperations.ClearAllBindings(xDSExpressionTxtbox); if (MappedType == eDataType.Variable.ToString()) { BindingHandler.ObjFieldBinding(xVariablesComboBox, ComboBox.SelectedValueProperty, this, nameof(MappedValue)); } else if (MappedType == eDataType.GlobalVariable.ToString()) { BindingHandler.ObjFieldBinding(xOptionalValuesComboBox, ComboBox.SelectedValueProperty, this, nameof(MappedValueGUID)); } else if (MappedType == eDataType.OutputVariable.ToString()) { BindingHandler.ObjFieldBinding(xOptionalValuesComboBox, ComboBox.SelectedValueProperty, this, nameof(MappedValueGUID)); } else if (MappedType == eDataType.ApplicationModelParameter.ToString()) { BindingHandler.ObjFieldBinding(xOptionalValuesComboBox, ComboBox.SelectedValueProperty, this, nameof(MappedValueGUID)); } else if (MappedType == eDataType.DataSource.ToString()) { BindingHandler.ObjFieldBinding(xDSExpressionTxtbox, TextBox.TextProperty, this, nameof(MappedValue)); } SetValueControlsData(); SetValueControlsView(); }
void RichBlocks_UnLoaded(object sender, RoutedEventArgs e) { vPanel.Children.Clear(); CommandBindings.Clear(); BindingOperations.ClearAllBindings(this); }
/// <summary> /// When overridden in a derived class, is invoked whenever /// application code or internal processes call ApplyTemplate /// </summary> public override void OnApplyTemplate() { if (this.textBoxTemplated != null) { this.textBoxTemplated.PreviewKeyDown -= this.OnTextBoxTemplatedKeyDown; this.textBoxTemplated.SelectionChanged -= this.OnTextBoxTemplatedSelectionChanged; this.textBoxTemplated.LostFocus -= this.OnTextBoxTemplatedLostFocus; this.textBoxTemplated.GotKeyboardFocus -= this.OnTextBoxTemplatedGotKeyboardFocus; this.textBoxTemplated.TextChanged -= this.OnTextBoxTemplatedTextChanged; BindingOperations.ClearAllBindings(this.textBoxTemplated); } this.textBoxTemplated = this.GetTemplateChild("PART_TextBox") as System.Windows.Controls.TextBox; // Check template if (!this.IsTemplateValid()) { Debug.WriteLine("Template for TextBox control is invalid"); return; } this.textBoxTemplated.Text = this.Text; this.textBoxTemplated.Select(this.textBox.SelectionStart, this.textBox.SelectionLength); // Bindings BindingOperations.ClearAllBindings(this.textBox); this.ForwardBindings(this, this.textBoxTemplated); this.textBoxTemplated.PreviewKeyDown += this.OnTextBoxTemplatedKeyDown; this.textBoxTemplated.SelectionChanged += this.OnTextBoxTemplatedSelectionChanged; this.textBoxTemplated.LostFocus += this.OnTextBoxTemplatedLostFocus; this.textBoxTemplated.GotKeyboardFocus += this.OnTextBoxTemplatedGotKeyboardFocus; this.textBoxTemplated.TextChanged += this.OnTextBoxTemplatedTextChanged; }
private void ResetContentViews() { if (smallContentGrid.Children.Count <= 0) { return; } var smallContentView = smallContentGrid.Children[0] as PreviewCompactView; BindingOperations.ClearAllBindings(smallContentView); // No view to reset, return now. if (largeContentGrid.Children.Count <= 0) { return; } var watchTree = largeContentGrid.Children[0] as WatchTree; var rootDataContext = watchTree.DataContext as WatchViewModel; // Unbind the view from data context, then clear the data context. BindingOperations.ClearAllBindings(watchTree.treeView1); BindingOperations.ClearAllBindings(watchTree.ListLevelsDisplay); rootDataContext.Children.Clear(); }
private void ClearBindings(object elem) { if ((elem as DependencyObject) != null) { BindingOperations.ClearAllBindings(elem as DependencyObject); } }
void SetRadioGroupBindings(SerialView Serial, NavigatingCancelEventArgs e) { BindingOperations.ClearAllBindings((e.Content as SerialInfoPage).rbStopWatching); BindingOperations.ClearAllBindings((e.Content as SerialInfoPage).rbWatched); BindingOperations.ClearAllBindings((e.Content as SerialInfoPage).rbWatching); Binding bind = new Binding(); bind.Source = Serial; bind.Path = new PropertyPath("Watching"); bind.Mode = BindingMode.TwoWay; (e.Content as SerialInfoPage).rbWatching.SetBinding(RadioButton.IsCheckedProperty, bind); Binding bind2 = new Binding(); bind2.Source = Serial; bind2.Path = new PropertyPath("Watched"); bind2.Mode = BindingMode.TwoWay; (e.Content as SerialInfoPage).rbWatched.SetBinding(RadioButton.IsCheckedProperty, bind2); Binding bind3 = new Binding(); bind3.Source = Serial; bind3.Path = new PropertyPath("DontWatch"); bind3.Mode = BindingMode.TwoWay; (e.Content as SerialInfoPage).rbStopWatching.SetBinding(RadioButton.IsCheckedProperty, bind3); }
private void ClearBindings(DependencyObject obj) { if (obj == null) { return; } BindingOperations.ClearAllBindings(obj); if (obj is Panel) { foreach (UIElement element in ((Panel)obj).Children) { ClearBindings(element); } } else if (obj is ItemsControl) { foreach (UIElement element in ((ItemsControl)obj).Items) { ClearBindings(element); } } else if (obj is ContentControl) { ClearBindings(((ContentControl)obj).Content as DependencyObject); } }
public override object Clone() { ShellDrillDownMenuItem clone = new ShellDrillDownMenuItem { Caption = this.Caption, Id = this.Id, IsBackItem = this.IsBackItem, IsEnabled = this.IsEnabled, IsFolder = this.IsFolder, IsReadOnly = this.IsReadOnly, AssemblyFile = this.AssemblyFile, IsAuthorized = this.IsAuthorized, Operation = this.Operation, Parameters = this.Parameters, EventTopic = this.EventTopic, }; BindingOperations.ClearAllBindings(clone); ObservableCollection <DrillDownMenuItem> children = new ObservableCollection <DrillDownMenuItem>(); foreach (DrillDownMenuItem child in this.Children) { DrillDownMenuItem childClone = child.Clone() as DrillDownMenuItem; childClone.Parent = clone; children.Add(childClone); } clone.Children = children; return(clone); }
public void OnDisposeGUIBot() { //looking at MainWindowViewModel.BindBotControls this.DataContext = null; GridSettings.Children.Clear(); //GridSettings.Children[0] = null; BindingOperations.ClearAllBindings(BotSate); BindingOperations.ClearAllBindings(this); BindingOperations.ClearAllBindings(this.EllipseEnabled); this.EllipseEnabled.DataContext = null; BindingOperations.ClearAllBindings(this.TextEnabled); this.TextEnabled.DataContext = null; BindingOperations.ClearAllBindings(this.MonitorPos); BindingOperations.ClearAllBindings(this.Orders); if (this.GUIBot != null) { this.GUIBot.MonitorPos.CollectionChanged -= this.OnMonitorPosCollectionChanged; this.GUIBot.Orders.CollectionChanged -= this.OnMonitorOrdersCollectionChanged; this.GUIBot.DisposeGUIBotEvent -= OnDisposeGUIBot; this.GUIBot = null; } BindingOperations.ClearAllBindings(this.ButtonPosLog); BindingOperations.ClearAllBindings(this.ButtonDisableBot); BindingOperations.ClearAllBindings(this.ButtonEnableBot); BindingOperations.ClearAllBindings(this.ButtonUnloadBot); }
protected override void OnElementChanged(ElementChangedEventArgs <GIFView> e) { base.OnElementChanged(e); if (e.OldElement != null) { } if (e.NewElement != null) { if (Control == null) { var control = new NativeGIFView(); SetNativeControl(control); } else { BindingOperations.ClearAllBindings(Control); } var binding1 = new Binding() { Source = e.NewElement, Path = new PropertyPath(nameof(GIFView.Source)) }; var binding2 = new Binding() { Source = e.NewElement, Path = new PropertyPath(nameof(GIFView.Stretch)), Converter = new StretchConverter() }; BindingOperations.SetBinding(Control, NativeGIFView.SourceProperty, binding1); BindingOperations.SetBinding(Control, NativeGIFView.StretchProperty, binding2); } }
private static Control ProvideHyperLinkControl(Binding binding, PropertyInfo propertyInfo, object viewModel) { var control = new ContentControl(); var text = (string)propertyInfo.GetValue(viewModel, null); var ln = new Run(text); var hyperlink = new Hyperlink(ln); hyperlink.SetBinding(Hyperlink.NavigateUriProperty, binding); hyperlink.RequestNavigate += (o, e) => { Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri)); e.Handled = true; }; hyperlink.Unloaded += (o, e) => { var hl = o as Hyperlink; if (hl == null) { return; } BindingOperations.ClearAllBindings(hl); }; control.SetValue(ContentControl.ContentProperty, hyperlink); return(control); }
public override void SetupCustomUIElements(object ui) { var nodeUI = ui as dynNodeView; watchTree = new WatchTree(); nodeUI.grid.Children.Add(watchTree); watchTree.SetValue(Grid.RowProperty, 2); watchTree.SetValue(Grid.ColumnSpanProperty, 3); watchTree.Margin = new Thickness(5, 0, 5, 5); if (Root == null) { Root = new WatchNode(); } watchTree.DataContext = Root; this.RequestBindingUnhook += new EventHandler(delegate { BindingOperations.ClearAllBindings(watchTree.treeView1); }); this.RequestBindingRehook += new EventHandler(delegate { var sourceBinding = new Binding("Children") { Mode = BindingMode.TwoWay, Source = Root, }; watchTree.treeView1.SetBinding(ItemsControl.ItemsSourceProperty, sourceBinding); }); }
public void Dispose() { this.textEditorSettings.PropertyChanged -= TextEditorSettings_PropertyChanged; Clear(); BindingOperations.ClearAllBindings(TextEditor); textMarkerService.Dispose(); }
public static void ClearAllBindings(this DependencyObject dependencyObject) { foreach (var element in dependencyObject.AllVisualChildren()) { BindingOperations.ClearAllBindings(element); } }
///<summary> Магическая чистка, которая позволяет GC почти сразу затирать BitmapImage из неуправляемой памяти. </summary> private void ForceLinkDestroy() { var albList = CatEng?.CatRoot?.AlbumsList; if (albList != null) { foreach (var alb in albList) { if (alb?.vp != null) { BindingOperations.ClearAllBindings(alb.vp.CoverArt); alb.vp.DataContext = null; alb.vp.CoverArt.Source = null; alb.vp.BG.Source = null; alb.vp = null; } alb.StopLoadEntCoversThread(); alb.CoverImage = null; foreach (var ent in alb.EntryList) { if (ent?.vp != null) { BindingOperations.ClearAllBindings(ent.vp.CoverArt); ent.vp.DataContext = null; ent.vp.CoverArt.Source = null; ent.vp.BG.Source = null; ent.vp = null; } ent.CoverImage = null; } } } }
public void ClearBindings() { ParentList.UcListViewEvent -= ParentList_UcListViewEvent; ParentList.List.SelectionChanged -= ParentList_SelectionChanged; ((RepositoryItemBase)Item).PropertyChanged -= Item_PropertyChanged; BindingOperations.ClearAllBindings(xItemIcon); foreach (ImageMakerControl notification in xItemNotificationsPnl.Children) { BindingOperations.ClearAllBindings(notification); } BindingOperations.ClearAllBindings(xItemStatusImage); BindingOperations.ClearAllBindings(xListItemGrid); foreach (ucButton operation in xItemOperationsPnl.Children) { BindingOperations.ClearAllBindings(operation); } foreach (MenuItem extraOperation in xItemExtraOperationsMenu.Items) { BindingOperations.ClearAllBindings(extraOperation); } foreach (ucButton executionOperation in xItemExecutionOperationsPnl.Children) { BindingOperations.ClearAllBindings(executionOperation); } this.ClearControlsBindings(); }
public static void ClearControlsBindings(this DependencyObject dependencyObject) { foreach (DependencyObject element in dependencyObject.EnumerateVisualDescendents()) { BindingOperations.ClearAllBindings(element); } }
private void TransitionControl_Unloaded(object sender, RoutedEventArgs e) { Unloaded -= TransitionControl_Unloaded; _transitionContainer?.Children.Clear(); BindingOperations.ClearAllBindings(this); }
public void Dispose() { UnregisterEventHandlers(); //for some reason the menuItem was not being gc'd in tests without manually removing it viewLoadedParams.dynamoMenu.Items.Remove(notificationsMenuItem.MenuItem); BindingOperations.ClearAllBindings(notificationsMenuItem.CountLabel); notificationsMenuItem = null; }
private void btnRemove_Click(object sender, RoutedEventArgs e) { #region Solution //BindingOperations.ClearAllBindings(this.tbZiel); #endregion BindingOperations.ClearAllBindings(this.tbZiel); }
private void UserControl_Unloaded(object sender, RoutedEventArgs e) { BindingOperations.ClearAllBindings(this); BindingOperations.ClearAllBindings(num); BindingOperations.ClearAllBindings(incr); incr.PostiveAndNegativeChanged -= Incr_PostiveAndNegativeChanged; }
private void OnUnloaded(object sender, RoutedEventArgs e) { Unloaded -= OnUnloaded; BindingOperations.ClearAllBindings(this); _plot.Plot.Clear(); }
private void ResetButton() { foreach (ToolButton item in buttonlist) { BindingOperations.ClearAllBindings(item); item.Background = Brushes.Transparent; item.C = null; } }