Category / Section
How to create float window based on children's desired size in WPF DockingManager?
1 min read
To create the float window based on the children window size, set an attached property SizeToContentInFloat of WPF DockingManager for the child window to True. By default, its value is False.
XAML
<Window x:Class="Application_New.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:shared="clr-namespace:Syncfusion.Windows.Tools.Controls;assembly=Syncfusion.Shared.Wpf" xmlns:syncfusion="http://schemas.syncfusion.com/wpf" Title="MainWindow" Height="350" Width="525"> <Grid x:Name="Grid1"> <syncfusion:DockingManager x:Name="DockingManager1"> <ContentControl Width="200" Height="24" syncfusion:DockingManager.Header="Child1" x:Name="Content1" syncfusion:DockingManager.State="Float" syncfusion:DockingManager.SizetoContentInFloat="True" /> </syncfusion:DockingManager> </Grid> </Window>
C#
using Syncfusion.Windows.Tools.Controls; namespace Application_New { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); DockingManager DockingManager1 = new DockingManager(); ContentControl content1 = new ContentControl(); content1.Width = 200; content1.Height = 24; DockingManager.SetHeader(content1, "Child1"); DockingManager.SetSizetoContentInFloat(content1, true); DockingManager.SetState(content1, DockState.Float); DockingManager1.Children.Add(content1); Grid1.Children.Add(DockingManager1); } } }
The following screenshot shows how the size of the float window arranged according to its content size.