Behavior Customization Options In Docking Manager | Syncfusion Blogs
Live Chat Icon For mobile
Live Chat Icon
Popular Categories.NET  (174).NET Core  (29).NET MAUI  (207)Angular  (109)ASP.NET  (51)ASP.NET Core  (82)ASP.NET MVC  (89)Azure  (41)Black Friday Deal  (1)Blazor  (215)BoldSign  (14)DocIO  (24)Essential JS 2  (107)Essential Studio  (200)File Formats  (66)Flutter  (133)JavaScript  (221)Microsoft  (119)PDF  (81)Python  (1)React  (100)Streamlit  (1)Succinctly series  (131)Syncfusion  (915)TypeScript  (33)Uno Platform  (3)UWP  (4)Vue  (45)Webinar  (51)Windows Forms  (61)WinUI  (68)WPF  (159)Xamarin  (161)XlsIO  (36)Other CategoriesBarcode  (5)BI  (29)Bold BI  (8)Bold Reports  (2)Build conference  (8)Business intelligence  (55)Button  (4)C#  (147)Chart  (131)Cloud  (15)Company  (443)Dashboard  (8)Data Science  (3)Data Validation  (8)DataGrid  (63)Development  (628)Doc  (8)DockingManager  (1)eBook  (99)Enterprise  (22)Entity Framework  (5)Essential Tools  (14)Excel  (40)Extensions  (22)File Manager  (7)Gantt  (18)Gauge  (12)Git  (5)Grid  (31)HTML  (13)Installer  (2)Knockout  (2)Language  (1)LINQPad  (1)Linux  (2)M-Commerce  (1)Metro Studio  (11)Mobile  (507)Mobile MVC  (9)OLAP server  (1)Open source  (1)Orubase  (12)Partners  (21)PDF viewer  (43)Performance  (12)PHP  (2)PivotGrid  (4)Predictive Analytics  (6)Report Server  (3)Reporting  (10)Reporting / Back Office  (11)Rich Text Editor  (12)Road Map  (12)Scheduler  (52)Security  (3)SfDataGrid  (9)Silverlight  (21)Sneak Peek  (31)Solution Services  (4)Spreadsheet  (11)SQL  (10)Stock Chart  (1)Surface  (4)Tablets  (5)Theme  (12)Tips and Tricks  (112)UI  (387)Uncategorized  (68)Unix  (2)User interface  (68)Visual State Manager  (2)Visual Studio  (31)Visual Studio Code  (19)Web  (592)What's new  (332)Windows 8  (19)Windows App  (2)Windows Phone  (15)Windows Phone 7  (9)WinRT  (26)

Behavior Customization Options In Docking Manager

Introduction

Silverlight Docking Manager new version which will be coming in our Volume 3 enables us to use the similar and complete docking functionality what we see in Visual Studio. We can customize the behavior of Docking Manager using many useful Properties and Events found in our class libraries. Main important thing to be notified is, we provide several new events to determine the behavior of a particular docking window at runtime.

You can listen each state changes and you can allow or cancel the each and every transition at runtime also. We can restrict a window from docking, dragging, resizing and autohiding directly or depending upon certain conditions. This post completely describes about the various possibilities of behavior customization with our Silverlight Docking Manager.

 

DockAbility

Indicates where the user can dock a window inside another window. It is flagged enumeration. By default, DockAbility will be set as DockAbility.All. So all drag indicators appear for all windows. It contains the following values,

PositionDescription
LeftLeft drag indicator will appear.
RightRight drag indicator will appear
TabbedCenter drag indicator will appear
TopTop drag indicator will appear
BottomBottom drag indicator will appear
NoneNo drag indicator will appear

Following code illustrates the DockAbility,

   
<syncfusion:dockingmanager name="”dockingManager”">
  <!--—DockAbility of Solution Explorer window is set to Left, Right, Top and Bottomà
  <system:TreeView syncfusion:DockingManager.Header=”Solution Explorer” syncfusion:DockingManager.SideInDockedMode=”Right” syncfusion:DockingManager.DockAbility=”Left,Right,Top,Bottom” syncfusion:DockingManager.DockState=”Dock” syncfusion:DockingManager.WindowName=”solutionexplorer” syncfusion:DockingManager.DesiredWidthInDockedMode=”150”-->
   
  ...
</syncfusion:dockingmanager>

[c#]

DockingManager.SetDockAbility(this.treeView, DockAbility.Left | DockAbility.Right | DockAbility.Top | DockAbility.Bottom);

In the image, center drag indicator does not appear in the Solution Explorer window since its DockAbility is set only for Left, Right, Top and Bottom.

DockAbility

 

Left, Right, Top and Bottom Drag Indicator

OuterDockAbility

Controls the visibility of outer drag providers. It is a flagged enumeration. By default, OuterDockAbility will be set as OuterDockAbility.All so all the outer drag indicators appear. It contains the following values,

PositionDescription
LeftLeft drag indicator will appear.
RightRight drag indicator will appear
TopTop drag indicator will appear
BottomBottom drag indicator will appear
NoneNo drag indicator will appear

Following code illustrates the OuterDockAbility to allow only for Left & Right side of the application,

<!--—OuterDockAbility is set to Left and Right---->
 <syncfusion:dockingmanager name="dockingManager" outerdockability="Left,Right">
    ...
 </syncfusion:dockingmanager>
this.dockingManager.OuterDockAbility = OuterDockAbility.Left | OuterDockAbility.Right;

In the below image, only left and right outer drag indicators are displayed since OuterDockAbility is set only for Left and Right.

OuterDockAbility

 

Left and Right Drag Indicator

FreezeLayout

The entire layout can be frozen by setting FreezeLayout property. When this property is set to false we cannot resize all the windows. This allows us to maintain the same layout.

[XAML]

<syncfusion:dockingmanager name="dockingManager" freezelayout="True">
 <!--Text window is Autohidden at top-->
<textbox syncfusion:dockingmanager.header="Text" syncfusion:dockingmanager.sideindockedmode="Top" syncfusion:dockingmanager.canresize="False" syncfusion:dockingmanager.dockstate="AutoHidden" syncfusion:dockingmanager.windowname="text"></textbox>
 </syncfusion:dockingmanager>

[c#]

this.dockingManager.FreezeLayout = true;

Prevent docking of a window into another docking window

A window can be prevented from docking in to another window in two ways.

1. Using CanDock property

2. Using DockAllow event

CanDock

If this property is set to false, a window cannot be docked to the side of other window. By default, this property will be set to True.

[XAML]

<textbox x_name="textBox" syncfusion:dockingmanager.header="Text" syncfusion:dockingmanager.sideindockedmode="Top" syncfusion:dockingmanager.candock="False" syncfusion:dockingmanager.dockstate="AutoHidden" syncfusion:dockingmanager.windowname="text"></textbox>

[c#]

DockingManager.SetCanDock(this.textBox, false);

DockAllow

This event will be fired when a control is about to be docked by mouse. This event can be cancelled. The event handler will have two parameters- sender and DockAllowEventArgs.

DockAllowEventArgs will have the following properties,

PropertyDescription
DraggedElementIt contains the control that is currently being dragged.
TargetElementIt contains the control on which the dragged control will be docked

Following code shows that when an element is about to be docked to TreeView element, event is cancelled.

[c#]

void dockingManager_DockAllow(object sender, DockAllowEventArgs args)
{
  if (args.TargetElement == this.treeView)
  {
     args.Cancel = true;
  }
}

Cancel the floating of docking window

We can cancel the floating of docked window in two ways,

1. Using CanFloat

2. Using DockStateChanging event.

CanFloat

When this property is set to false, a window can be dragged but it won’t allow it to float if we release the mouse. By default this property will be set to True.

[XAML]

<textbox x_name="textBox" syncfusion:dockingmanager.header="Text" syncfusion:dockingmanager.sideindockedmode="Top" syncfusion:dockingmanager.canfloat="False" syncfusion:dockingmanager.dockstate="AutoHidden" syncfusion:dockingmanager.windowname="text"></textbox>

[c#]

 DockingManager.SetCanFloat(this.textBox, false);

DockStateChanging

We can cancel the floating of a window by cancelling this event whenever a DockState is changing to Float .

[c#]

 void dockingManager_DockStateChanging(object sender, DockStateChangingEventArgs args)
  {
    if ((DockState)args.NewState == DockState.Float)
    {
      args.Cancel = true;
    }
  }

Cancel state transition completely

State transition can be cancelled using DockStateChanging event. This event can be cancelled. The event handler has two parameters- sender object and DockStateChangingEventArgs.

DockStateChangingEventArgs has three properties,

PropertiesDescription
UIElementThe element which changes the state
OldStateIt contains the previous DockState of the element
NewStateIt contains the new DockState to which the element is going to be changed.

[c#]

void dockingManager_DockStateChanging(object sender, DockStateChangingEventArgs args)
 {
    args.Cancel = true;
  }

Prevent a window from Autohiding

If we set CanAutoHide property to false for a window, the window cannot be autohidden. It can also be achieved by cancelling DockStateChanging event when the window’s state is changing to Autohide.

[c#]

 void dockingManager_DockStateChanging(object sender, DockStateChangingEventArgs args)
  {
     if ((DockState)args.NewState == DockState.AutoHidden)
     {
         args.Cancel=true;
      }
  }

Prevent closing of a docking window

We can prevent docking window from closing in three ways,

CanClose

When this property is set to false, we will not be able to close a window.

[XAML]

<textbox x_name="textBox" syncfusion:dockingmanager.header="Text" syncfusion:dockingmanager.sideindockedmode="Top" syncfusion:dockingmanager.canclose="False" syncfusion:dockingmanager.dockstate="AutoHidden" syncfusion:dockingmanager.windowname="text"></textbox>

[c#]

DockingManager.SetCanClose(this.textBox, false);

PreviewWindowClosed

This event will be raised before a window is getting closed. CloseEventArgs contains two properties,

PropertiesDescription
ElementThe element which is being closed
CanceledEvent can be cancelled by setting true.

If the event is cancelled we cannot close the window.

[c#]

void dockingManager_PreviewWindowClosed(object sender, CloseEventArgs args)
 {
     args.Canceled = true;
 }

DockStateChanging

This event is raised when DockState is changing for a window. If the DockState is changing to Hidden state it indicates that window is closing. Here we can cancel the window.

[c#]

void dockingManager_PreviewWindowClosed(object sender, CloseEventArgs args)
 {
     args.Canceled = true;
 }

Maximize a particular window on load itself

Particular window can be maximized on load by specifying its maximized state using MaximizedState property. It accepts two values MaximizedState.Maximized and MaximizedState.Restored. Only one window can be maximized at a time.

[XAML]

<syncfusion:dockingmanager name="dockingManager" dockfill="True" showmaximizebutton="True">
 <!-- Solution Explorer window is Maximized-->
 <system:treeview syncfusion:dockingmanager.header="Solution Explorer" syncfusion:dockingmanager.sideindockedmode="Right" syncfusion:dockingmanager.maximizedstate="Maximized" syncfusion:dockingmanager.dockstate="Dock" syncfusion:dockingmanager.windowname="solutionexplorer" syncfusion:dockingmanager.desiredwidthindockedmode="150">
</system:treeview>
   ... 
 </syncfusion:dockingmanager>

[c#]

DockingManager.SetMaximizedState(this.treeView, MaximizedState.Maximized);

MaximizeOnLoad

Solution Explorer window is Maximized

Prevent a particular window from maximizing

We can prevent a particular window from maximizing by setting MaximizeButtonVisible property to false or we can cancel the Maximizing event. This event will be raised when a particular window is maximizing. In the below example it checks whether the window containing TreeView is Maximizing. If so, event is cancelled.

[c#]

this.dockingManager.Maximizing += new MaximizingEventHandler(dockingManager_Maximizing);
void dockingManager_Maximizing(object sender, MaximizingEventArgs args)
{
   if (args.UIElement == this.treeView)
    {
      args.Cancel = true;
    }
}

Conclusion

I hope you would have enjoyed with these features since we provide maximum extent possibilities of behavior customization with our Silverlight Docking manager. We welcome more feedback from you to enhance this feature based on real time experience.

Tags:

Share this post:

Popular Now

Be the first to get updates

Subscribe RSS feed