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.
If the SplitPane is still part of the XamDockManager then you can use the attached inherited DockManager property to get to it - e.g. XamDockManager.GetDockManager(splitPane).
Maybe I am missing something but the following code, gives null for xamDockManager2
XamDockManager xamDockManager = new XamDockManager();SplitPane splitPane1 = new SplitPane();xamDockManager.Panes.Add(splitPane1);XamDockManager xamDockManager2 = XamDockManager.GetDockManager(splitPane1);
Calling BeginInit and EndInit methods allows me to get the xamDockManager2 in the code above.
However when activating a ContentPane (ie calling contentPane.Activate() method), xamDockManager.ActivePane is nullThis doesn't happen if xamDockMager is created in XAML code.
Any other hint or tip ?
Thanks,Claudio
I'm not sure at what point (with respect to its creation and with respect to the display/load state of the containing window) you are comparing the ActivePane between one created in xaml and one created in code so I cannot say why you are seeing a difference. The ActivePane is tied to the element with keyboard focus. If the ActivePane is null then you must not have keyboard focus within any content pane.
In both cases I don't have the keyboard focus; by code I am invoking contentPane.Activate()
when created in XAML xamDockManager.ActivePane==contentPane
but in the UnitTest (where I create the xamDockManager in code),and invoke the same code it xamDockManager.ActivePane is null.
I will try to elaborate a simple case (since this is also mixed with the Composite WPF TabGroupPaneRegionAdapter I am elaborating).
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.
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.
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