Hi,
I have the following code (used as part of a unit test),
xamDockManager = new XamDockManager(); splitPane = new SplitPane(); xamDockManager.Panes.Add(splitPane);
At a later step (where I don't have the xamDockManager reference, only the splitPane), I need to get the xamDockManager where the splitPane belongs. Testing splitPane.Parent gives me null. Is this correct ? Is there other way to get the associated xamDockManager if I only have the splitPane available ?
Thanks,Claudio.
Well for XamDockManager Activate relates to giving the pane keyboard focus and the ActivePane is tied to whether a ContentPane contains the keyboard focus so I'm not sure what you want to consider active for your purposes.
Ok.
I just need to check that after calling contentPane.Activate() method that contentPane is indeed active.Maybe there is an easier way of doing this instead of using the xamDockManager.ActivePane property ?
Thanks again,Claudio
This is correct behavior. The XamDockManager doesn't control the WPF Framework's focused element - it just reacts to what has the keyboard focus. In your console application case, System.Windows.Input.Keyboard.FocusedElement will always be null. This isn't anything that we have any control over. You would have to put the XamDockManager into a Window, show that Window and make sure that that Window is active.
Here I have a sample code (I can send you the VS solution if necessary):
XAML
<Window x:Class="XamDockManagerActivePane.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" Height="300" Width="300"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <igDock:XamDockManager Grid.Row="0" x:Name="dockManager"> </igDock:XamDockManager> <Button Grid.Row="1" Click="Button_Click" Content="Generate Dock Manager"></Button> </Grid></Window>
Code Behind:
private void Button_Click(object sender, RoutedEventArgs e) { SplitPane splitPane1 = new SplitPane(); dockManager.Panes.Add(splitPane1); TabGroupPane tabGroupPane = new TabGroupPane(); ContentPane newContentPane = new ContentPane(); tabGroupPane.Items.Add(newContentPane); splitPane1.Panes.Add(tabGroupPane); newContentPane.Activate(); Console.WriteLine(dockManager.ActivePane); }
Console App:
[STAThread] static void Main(string[ args) { XamDockManager dockManager = new XamDockManager(); dockManager.BeginInit(); SplitPane splitPane1 = new SplitPane(); dockManager.Panes.Add(splitPane1); TabGroupPane tabGroupPane = new TabGroupPane(); ContentPane newContentPane = new ContentPane(); tabGroupPane.Items.Add(newContentPane); splitPane1.Panes.Add(tabGroupPane); newContentPane.Activate(); dockManager.EndInit(); Console.WriteLine(dockManager.ActivePane); }
In the XAML case it dockManager.ActivePane gives newContentPane. In the Console App case dockManager.ActivePane is null.
Again, the ActivePane will be null if the pane doesn't have keyboard focus. In the case where you just run an app, the application is active and therefore the element will actually get keyboard focus when you call Activate. When you're doing this in a unit test, its likely that the window (and possibly the application/process itself) containing the dockmanager (or any other element) is not active. This really isn't specific to XamDockManager. Try focusing any element and see if you can get its IsKeyboardFocusWithin to return true. If focus can't go into the contentpane then the ActivePane will be null.