Articles in this section
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:

Focusing label item in WPF DockingManager

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied