How to set the height and width of the usercontrol registered as toolwindow using Prism Integration.

Docking/MDI for WPF Forum

Posted 12 years ago by keshav bansal
Version: 11.2.0553
Avatar

Hi,

How to set the height and width of the usercontrol during run time which  is registered as the toolwindow inside the docksite with the help of the Docking with PrismIntegration.

Forexample :Consider i have one  Usercontrol named Usercontrol1 and a  main shell named Shell. As i run the application i am registering the usercontrol Usercontrol1 as the toolwindow with the help of the PrismIntegration so that i can dock the usercontrol.But the problem that i am facing  is like my usercontrol Usercontrol1 is covering very large area of the main shell named Shell.So i want to fix the height and width of the usercontrol after registering it as the toolwindow inside the main shell named Shell.

Comments (3)

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

Hi Keshav,

You would need to call DockSite.SetControlSize(toolWindow, new Size(150, 150)) on your ToolWindow before opening it. In our Prism example, this would need to be done in the IDockingWindowInitializer.Initialize method of the associated view model.


Actipro Software Support

Posted 12 years ago by keshav bansal
Avatar

Hi,

From the  function Docksite.SetControlSize(toolWindow, new Size(150, 150)) used in the Initialize function of the IDockingWindowInitializer,I am not able to set the height of the usercontrol which is registered as the toolwindow in the main shell with the help of the PrismIntegration with docking.I can set only width of the usercontrol from the above function in the main shell.

Code used.

 

public void Initialize(DockingWindow dockingWindow, objectitem)

{

if (dockingWindow == null)

thrownewArgumentNullException("dockingWindow");

dockingWindow.Name ="AblationToolWindow";

dockingWindow.Title ="Abaltion View";

ToolWindow toolwindow = dockingWindow asToolWindow;

DockSite.SetControlSize(toolwindow, newSize(50,10));

dockingWindow.ImageSource =newBitmapImage(newUri("/Resources/Images/SolutionExplorer16.png", UriKind.Relative));

}

public void Open(DockingWindow dockingWindow, objectitem)

{

if (dockingWindow == null)

thrownewArgumentNullException("dockingWindow");

ToolWindow toolWindow = dockingWindow asToolWindow;

if (dockSite != null && toolWindow != null){

ToolWindow relativeToolWindow = dockSite.ToolWindows["VitalToolWindow"];

if (relativeToolWindow != null)

{

toolWindow.Dock(relativeToolWindow,Direction.Content);

}

else

{

toolWindow.Dock(dockSite,

Direction.Right);

toolWindow.CanAutoHide =false;

toolWindow.CanRaft = false;

toolWindow.HasOptions =false;

toolWindow.CanClose =

false;

}

}

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

Hi Keshav,

If I put that code in our Prism Integration sample, for example in the SolutionExplorerToolItemViewModel class, then I can see that the size is properly applied. The complete method that would be in the SolutionExplorerToolItemViewModel class would be:

/// <summary>
/// Initializes the specified docking window with any associated metadata.
/// </summary>
/// <param name="dockingWindow">The docking window that should be initialized.</param>
/// <param name="item">The associated item.</param>
public void Initialize(DockingWindow dockingWindow, object item) {
	if (dockingWindow == null)
		throw new ArgumentNullException("dockingWindow");

	dockingWindow.ImageSource = new BitmapImage(new Uri("/Resources/Images/SolutionExplorer16.png", UriKind.Relative));
	dockingWindow.Name = "solutionExplorerToolWindow";
	dockingWindow.Title = "Solution Explorer";
	DockSite.SetControlSize(dockingWindow, new System.Windows.Size(50,10));
}

Keep in mind, that the ToolWindow will only use the specified Width when docked on the left/right sides, and will only use the specified Height when docked on the top/bottom sides.


Actipro Software Support

The latest build of this product (v24.1.2) was released 1 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.