How to change the visibility of Float window as visible which is not in selectedtab
While changing the selection in TabControl, TabItem content will be Collapsed other than selected tab. So FloatWindows will be visible only when the Parent TabItem is Selected. It is the default behavior of the TabControl.
We can overcome this behavior by changing the IsOpen property of the NativeFloatWindow as True. The same has been demonstrated in the following code.
MainWindow.xaml
<syncfusion:TabControlExt IsDisableUnloadTabItemExtContent="True" LayoutUpdated="TabControlExt_LayoutUpdated" > <syncfusion:TabItemExt Header=" Tab1"> <local:UserControl_one /> </syncfusion:TabItemExt> <syncfusion:TabItemExt Header=" Tab2"> <local:UserControl_two /> </syncfusion:TabItemExt> </syncfusion:TabControlExt>
MainWindow.cs
public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } private void TabControlExt_LayoutUpdated(object sender, EventArgs e) { foreach (var window in Application.Current.Windows) { if (window is NativeFloatWindow) { foreach (var content in FloatedCollection) { if (VisualUtils.FindRootVisual(content as Visual) == window) { NativeFloatWindow win = window as NativeFloatWindow; win.IsOpen = true; } } } } } public static ObservableCollection<DependencyObject> FloatedCollection = new ObservableCollection<DependencyObject>(); }
UserControl.xaml:
<syncfusion:DockingManager x:Name="dockingmanager_one" UseNativeFloatWindow="True" DockStateChanged="dockingmanager_one_DockStateChanged"> <ContentControl x:Name="content" syncfusion:DockingManager.Header="Window"/> </syncfusion:DockingManager>
UserControl.cs
public partial class UserControl_one : UserControl { public UserControl_one() { InitializeComponent(); } private void dockingmanager_one_DockStateChanged(FrameworkElement sender, Syncfusion.Windows.Tools.Controls.DockStateEventArgs e) { if (e.NewState == DockState.Float) { MainWindow.FloatedCollection.Add(sender); } else MainWindow.FloatedCollection.Remove(sender); } }
Output:
Float Window(“Window”) is the child of Tab1, but “Window” is visible even if the Tab1 is not selected.