Programatically set the width of the toolwindow which present in the AutoHideLeftContainer.

Docking/MDI for WPF Forum

Posted 6 years ago by keshav bansal
Version: 12.2.0571
Avatar

Hi,

How to Programatically set the width of the toolwindow which exists inside  the AutoHideLeftContainer.

<docking:DockSite x:Name="BaseDocksite1">

<docking:DockSite.AutoHideLeftContainers>

<docking:ToolWindowContainer><docking:ToolWindow x:Name="Toolwindow1" Width="150" Title="window1" CanRaft="True">

<Grid><Button Height="Auto" Content="xfdfdffffffffffffffffff" Click="Button_Click_1"></Button></Grid>

</docking:ToolWindow></docking:ToolWindowContainer>

</docking:DockSite.AutoHideLeftContainers>

<docking:Workspace>

<Grid>

<docking:DockSite x:Name="docksite2" WindowStateChanged="docksite2_WindowStateChanged">

<docking:ToolWindowContainer x:Name="container1">

<docking:ToolWindow x:Name="Toolwindow2" Title="window2"></docking:ToolWindow></docking:ToolWindowContainer>

</docking:DockSite>

</Grid></docking:Workspace></docking:DockSite>

 

In my above example i have docksite2 which is linkked with the basedocksite.

As i run the above simple docking application,there is one auto hide tab and a toolwindow2 alligned to each other ,when i click on the pin,toolwindow1 of width 100 will converted from the tabbed from to docked state,Now this toolwindow consist of the button.This toolwindow exists in the AutoHideLeftContainers of the Basedocksite.

When i click on the button inside the toolwindow1,i want to programatically increase the width of the toolwindow1 from 100 to 200;

Code used s

privatevoid Button_Click_1(object sender, RoutedEventArgse)

{

Toolwindow1.Width = 300;  //Not Working

(Toolwindow1.ParentContainer).Width = 300; //Not Working

DockSite.SetControlSize(Toolwindow1,new Size(200,1200));//Not Working

}

Comments (3)

Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Keshav,

I'm not sure you can dynamically update the width of the auto-hide tool window.  You may need to have it slide back in, then use DockSite.SetControlSize() on it, then Activate it again. That might get its width to be updated.


Actipro Software Support

Posted 6 years ago by keshav bansal
Avatar

Hi,

Above solution  not sovles the problem whole problem but it solves partially.

Suppose i have two columns in the wpf Grid of the Main application and i am registering the Wpf userfcontrol as the toolwindows in the respective columns of the grid like belowed code

<Grid.ColujmnDefinitions>

<ColumnDefinition width="Auto"></ColumnDefinition>

<ColumnDefinition width="*"></ColumnDefinition>

</Grid.ColujmnDefinitions>

I am registering the user controls as the toolwindow using the PrismItegration with docking.

I have one Basedocksite for the both of the docksite windows like

<Docksite x:Name="BaseDocksite">

<Docksite Grid.Column="0" x:Name="Docksite1"></></Docksite>

<Docksite Grid.Column="1" x:Name="Docksite2"></Docksite>

</Docksite>

These above docksites(Docksite1,Docksite2) act as the Region for registering the usercontrol as the toolwindow with the Help of PrismIntegration with docking.These above docksites(Docksite1,Docksite2) are linked with the BaseDocksite.

Once i run the application two toolwindows named toolwindow1 and toolwindow2 displayed in the respective docksites named Docksite1,Docksite2.

Suppose the width of the toolwindow1 is 230.

As i click on the AutoHide pin icon of the toolwindow1 then i am handling the docksite1 window state changte event an in that   i am removing  the toolwindow1 from the docksite1 and adding that toolwindow in the AutoHideLeftContainer of the BaseDocksite Because toolwindow1  exists in the Auto width column.Now when i hover the mouse i am increasing the width of the toolwindow1 using the belowed code but this width should be maintained when i am again click on the pin button for docking that toookwindow1(while converting the toolwindow1 from AutoHide state into Docked state) while it is inside the AuoHideLeftContainer of the BaseDocksite.But now toolwindow1 width is same as it was 230 not 250 while converting the toolwindow1 from AutoHide state into Docked state)

 

Code used  is

void

dockSite1_WindowStateChanged(object sender, DockingWindowStateChangedEventArgse)

{

if (e.Window.State.ToString() == DockignWindowState.AutoHide)

{

DockSite.SetControlSize(toolwindow1 , newSize(250, 650));toolwindow1 .Activate();

DockSite.SetControlSize(toolwindow1 .ParentContainer, newSize(250, 650));

ToolWindowContainer con = newToolWindowContainer();

if (reviewToolWindow.Parent != null){

ToolWindowContainer ablContainer = toolwindow1 .Parent asToolWindowContainer;

if (ablContainer != null)

{

ablContainer.Items.Remove(toolwindow1 );

tcon.Items.Add(toolwindow1 );

BaseDocksite.AutoHideLeftContainers.Add(con);

}

if (e.Window.State.ToString() == DockignWindowState.Docked)

{

DockSite.SetControlSize(toolwindow1 , newSize(250, 650));toolwindow1 .Activate();

}

}

}

}

Problem: Initially the width of the toolwindow1 is 230. But when i click on the AutoHide pin icon of the toolwindow1 then i am  adding that toolwindow1 in the AutoHideLeftContainer of the BaseDocksite  .when i  hover the mouse over the tabbed form of teh toolwindow I AM ABLE TO INCREASE THE WIDTH OF THE TOOLWINDOW1 FROM 230 TO 250.

BUT when i am again click on the pin button OF TOOLWINDOW1 for docking that toookwindow1 while it is inside the AuoHideLeftContainer of the BaseDocksite ITS DISPLAYING THE TOOLWINDOW1 IN DOCKED STATE BUT OF WIDTH 230 NOT OF 250.

Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Sorry, I'm not really following your code, and as we've told you in the past you should never be creating containers in code, which you are doing here.  That will not work.  Instead remove your tool window from the base dock site site when in auto-hide, call DockSite.SetControlSizeForState() (and pass in the Docked state as a parameter), add the tool window to the dockSite1 again, then call the tool window's Dock() method to dock it. 

SetControlSize() will only update the control size for the current state it's in (which may be auto-hide at the time you're trying it).  So to get it to update the Docked state's size, call SetControlSizeForState() and pass the Docked state.


Actipro Software Support

The latest build of this product (v2018.1 build 0675) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.