'宣言 Public Shared ReadOnly AllowCloseProperty As DependencyProperty
public static readonly DependencyProperty AllowCloseProperty
Imports Infragistics.Windows.DockManager Imports Infragistics.Windows.DockManager.Events Private Sub ContentPane_Closing(ByVal sender As Object, ByVal e As PaneClosingEventArgs) Dim result As MessageBoxResult = MessageBox.Show(Me, "Can this pane be hidden?", "Close Pane", MessageBoxButton.YesNo, MessageBoxImage.Question) If MessageBoxResult.No = result Then e.Cancel = True End If End Sub Private Sub ContentPane_Closed(ByVal sender As Object, ByVal e As PaneClosedEventArgs) Dim cp As ContentPane = TryCast(e.OriginalSource, ContentPane) System.Diagnostics.Debug.WriteLine(cp.Header, "Closed") End Sub Private Sub InitializeDmClosePane(ByVal dockManager As XamDockManager) Dim split As New SplitPane() ' By default when a pane is closed, it ' is just hidden. For some panes though ' you may just want the pane to be removed. ' The CloseAction can be used to control this. Dim cpRemove As New ContentPane() cpRemove.CloseAction = PaneCloseAction.RemovePane cpRemove.Header = "Remove When Closed" split.Panes.Add(cpRemove) ' You can prevent a pane from being closed using ' the AllowClose property. By default all panes ' can be closed and when closed the Visibility ' is changed to Collapsed. Dim cpNever As New ContentPane() cpNever.AllowClose = False cpNever.Header = "Never Close" split.Panes.Add(cpNever) ' You can handle the Closing event to conditionally ' prevent the pane from being closed. The Closed ' event is fired after the pane has been closed ' regardless of the CloseAction Dim cpConditional As New ContentPane() cpConditional.Header = "Conditionally Close" AddHandler cpConditional.Closing, AddressOf Me.ContentPane_Closing AddHandler cpConditional.Closed, AddressOf Me.ContentPane_Closed split.Panes.Add(cpConditional) dockManager.Panes.Add(split) End Sub
using Infragistics.Windows.DockManager; using Infragistics.Windows.DockManager.Events; private void ContentPane_Closing(object sender, PaneClosingEventArgs e) { MessageBoxResult result = MessageBox.Show(this, "Can this pane be hidden?", "Close Pane", MessageBoxButton.YesNo, MessageBoxImage.Question); if (MessageBoxResult.No == result) { e.Cancel = true; } } private void ContentPane_Closed(object sender, PaneClosedEventArgs e) { ContentPane cp = e.OriginalSource as ContentPane; System.Diagnostics.Debug.WriteLine(cp.Header, "Closed"); } private void InitializeDmClosePane(XamDockManager dockManager) { SplitPane split = new SplitPane(); // By default when a pane is closed, it // is just hidden. For some panes though // you may just want the pane to be removed. // The CloseAction can be used to control this. ContentPane cpRemove = new ContentPane(); cpRemove.CloseAction = PaneCloseAction.RemovePane; cpRemove.Header = "Remove When Closed"; split.Panes.Add(cpRemove); // You can prevent a pane from being closed using // the AllowClose property. By default all panes // can be closed and when closed the Visibility // is changed to Collapsed. ContentPane cpNever = new ContentPane(); cpNever.AllowClose = false; cpNever.Header = "Never Close"; split.Panes.Add(cpNever); // You can handle the Closing event to conditionally // prevent the pane from being closed. The Closed // event is fired after the pane has been closed // regardless of the CloseAction ContentPane cpConditional = new ContentPane(); cpConditional.Header = "Conditionally Close"; cpConditional.Closing += new EventHandler<PaneClosingEventArgs>(this.ContentPane_Closing); cpConditional.Closed += new EventHandler<PaneClosedEventArgs>(this.ContentPane_Closed); split.Panes.Add(cpConditional); dockManager.Panes.Add(split); }