As part of the adapter I am coding, when a View is Deactivated I need to Deactivate the associated ContentPane.
I don't want closing the ContentPane (I am doing that when the View is removed), I would like to do something like xamDockManager.ActivePane=null (as the initial state of xamDockManager). But that property is readOnly.
Any thoughts ?
Thanks,Claudio.
The ActivePane is tied to the Keyboard.FocusedElement - if focus is within the pane then it is considered active. If you want something else to be active then you need to shift the keyboard focus elsewhere - i.e. use the Focus or MoveFocus method of some other element.
Andrew,
I did a small sample with your suggestion but it's not working. Below is the code and output.
Notice the last 2 cases where :
Keyboard.FocusedElement - System.Windows.Controls.Button: Activate and Deactivate Pane
but
Current Active Pane - Infragistics.Windows.DockManager.ContentPane Header:Right Edge Dock Pane Content:Content Pane
Am I missing something else ?
----------CODE STARTS---------
XAML
<Window x:Class="DeactivatePane.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:igDock="http://infragistics.com/DockManager" Title="Window1" Name="win" Height="300" Width="300"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="*"/> <RowDefinition Height="50"/> </Grid.RowDefinitions> <igDock:XamDockManager x:Name="dockManager" Grid.Row="0" > <igDock:XamDockManager.Panes> <igDock:SplitPane> <igDock:ContentPane x:Name="contentPane" Header="Right Edge Dock Pane"> <TextBox>Content Pane</TextBox> </igDock:ContentPane> </igDock:SplitPane> </igDock:XamDockManager.Panes> </igDock:XamDockManager> <Button Name="btnActivateAndDeactivate" Content="Activate and Deactivate Pane" Grid.Row="1" Click="btnActivateDeactivate_Click" ></Button> </Grid></Window>
C#:
private void btnActivateDeactivate_Click(object sender, RoutedEventArgs e) { Console.WriteLine("\n\nActivating Pane"); contentPane.Activate(); DisplayActivePane(); Console.WriteLine("\n\nTrying to Deactivate Pane - Focus on Window (via Focus() method)"); win.Focus(); DisplayActivePane(); Console.WriteLine("\n\nTrying to Deactivate Pane - Focus on Window (via Keyboard)"); Keyboard.Focus(win); DisplayActivePane(); Console.WriteLine("\n\nTrying to Deactivate Pane - MoveFocus() method"); contentPane.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next)); DisplayActivePane(); Console.WriteLine("\n\nTrying to Deactivate Pane - Focus on Button (via Focus() method)"); btnActivateAndDeactivate.Focus(); DisplayActivePane(); Console.WriteLine("\n\nTrying to Deactivate Pane - Focus on Button (via Keyboard)"); Keyboard.Focus(btnActivateAndDeactivate); DisplayActivePane(); } private void DisplayActivePane() { Console.WriteLine("Keyboard.FocusedElement - " + Keyboard.FocusedElement); Console.WriteLine("Current Active Pane - " +dockManager.ActivePane); }
----------CODE ENDS---------
----------OUTPUT START---------
Activating PaneKeyboard.FocusedElement - System.Windows.Controls.TextBox: Content PaneCurrent Active Pane - Infragistics.Windows.DockManager.ContentPane Header:Right Edge Dock Pane Content:Content PaneTrying to Deactivate Pane - Focus on Window (via Focus() method)Keyboard.FocusedElement - System.Windows.Controls.TextBox: Content PaneCurrent Active Pane - Infragistics.Windows.DockManager.ContentPane Header:Right Edge Dock Pane Content:Content PaneTrying to Deactivate Pane - Focus on Window (via Keyboard)Keyboard.FocusedElement - System.Windows.Controls.TextBox: Content PaneCurrent Active Pane - Infragistics.Windows.DockManager.ContentPane Header:Right Edge Dock Pane Content:Content PaneTrying to Deactivate Pane - MoveFocus() methodKeyboard.FocusedElement - System.Windows.Controls.TextBox: Content PaneCurrent Active Pane - Infragistics.Windows.DockManager.ContentPane Header:Right Edge Dock Pane Content:Content PaneTrying to Deactivate Pane - Focus on Button (via Focus() method)Keyboard.FocusedElement - System.Windows.Controls.Button: Activate and Deactivate PaneCurrent Active Pane - Infragistics.Windows.DockManager.ContentPane Header:Right Edge Dock Pane Content:Content PaneTrying to Deactivate Pane - Focus on Button (via Keyboard)Keyboard.FocusedElement - System.Windows.Controls.Button: Activate and Deactivate PaneCurrent Active Pane - Infragistics.Windows.DockManager.ContentPane Header:Right Edge Dock Pane Content:Content Pane
----------OUTPUT ENDS---------
Sorry I didn't mean to imply its a synchronous change - just that it is based upon the focused element. We delay changing the active pane in case focus is shifting from one pane to another or focus is leaving the pane only to come back into the pane because its being moved from floating to docked or vice versa. If we didn't delay then you would get a lot of unneeded ActivePaneChanged events and changes to the ActivePane. The ActivePaneChanged event will be invoked once the activepane has been changed.