public void RemovePane(UserControl uIElement) { if (Panes.Where(a => a.Content == uIElement).Count() > 0) { Panes.Remove(Panes.Single(a => a.Content == uIElement)); } }
public void AddPane(UserControl UIElement) { if (UIElement.DataContext is Models.ViewModelPane vm) { if (Panes.Where(a => a.Header?.ToString().Replace("*", "") == vm.Header.Replace("*", "") && a.IsVisible).Count() > 0) { ShowPane(Panes.Single(a => a.Header?.ToString().Replace("*", "") == vm.Header.Replace("*", "") && a.IsVisible)); } else { var pane = new RadPane { Content = UIElement, }; vm.CloseAction = new Action(() => { pane.IsHidden = true; }); pane.DataContext = vm; pane.IsVisibleChanged += (sender, e) => { }; Binding binding = new Binding(); binding.Path = new PropertyPath("Header"); // свойство элемента-источника pane.SetBinding(RadPane.HeaderProperty, binding); // установка привязки для элемента-приемника Panes.Add(pane); } } else if (UIElement.DataContext is Models.ViewModelPaneReactiveObject vm2) { if (Panes.Where(a => a.Header?.ToString().Replace("*", "") == vm2.Header.Replace("*", "") && a.IsVisible).Count() > 0) { ShowPane(Panes.Single(a => a.Header?.ToString().Replace("*", "") == vm2.Header.Replace("*", "") && a.IsVisible)); } else { var pane = new RadPane { Content = UIElement, }; vm2.CloseAction = new Action(() => { pane.IsHidden = true; }); pane.DataContext = vm2; pane.IsVisibleChanged += (sender, e) => { }; Binding binding = new Binding(); binding.Path = new PropertyPath("Header"); // свойство элемента-источника pane.SetBinding(RadPane.HeaderProperty, binding); // установка привязки для элемента-приемника Panes.Add(pane); } } }