Category / Section
How to focus item inside the contentcontrol after activewindow changed in WPF DockingManager document?
1 min read
This article describes how to focus item inside the ContentControl after ActiveWindow Changed in DockingManager.
Use DocumentTabItem Style to set the Focusable property for TabItem in WPF DockingManager. By Setting Focusable property of TabItem as false, then it allows to focus the item inside the ContentControl after ActiveWindow changed.
The following code example demonstrates the same.
XAML
<Syncfusion:DockingManager x:Name="x_dock" UseDocumentContainer="True" TabGroupEnabled="False"> <Syncfusion:DockingManager.DocumentTabItemStyle> <Style TargetType="Syncfusion:TabItemExt"> <Setter Property="Focusable" Value="False"/> </Style> </Syncfusion:DockingManager.DocumentTabItemStyle> </Syncfusion:DockingManager>
C#
public MainWindow() { InitializeComponent(); Populate(); (x_dock.DocContainer as DocumentContainer).Loaded += MainWindow_Loaded; } TextBox newControl = null; private void MainWindow_Loaded(object sender, RoutedEventArgs e) { if (newControl != null) newControl.Focus(); } private void Populate() { for (int i = 0; i < 5; i++) { newControl = new TextBox() { Text = "Label " + i }; DockingManager.SetHeader(newControl, "Label " + i); DockingManager.SetState(newControl, DockState.Document); x_dock.Children.Add(newControl); } }
The output for the above code is shown below: