VsPackage - ToolWindow - how to use Window.Forms.UserControl instead of Default WPF control
-
Friday, September 14, 2012 5:41 PM
Hi, I have just started learning VSX. So please do not mind if the question looks stupid.
When we create a new VS Package project with ToolWindow, by default a control MyControl.xaml will be added which will be tied to the ToolWindow.
How to use a normal usercontrol dervied from Windows.Forms.UserControl?
I tried added a usercontrol in the project and changed the code in the MyToolWindow.cs to use that control but all I see is blank Toolwindow if i debug.
//Normal code in auto generated MyToolWindow.cs
base.Content = new MyControl();//The usercontrol i created is SimpleControl. I have changed the code to.
base.Content = new SimpleControl();Other details:
Visual Studio 2010 Premium SP1
Windows 7 Professional 64 bit.- Edited by Syed Aziz ur Rahman Friday, September 14, 2012 5:46 PM Enviroment details
All Replies
-
Friday, September 14, 2012 9:30 PMModerator
Hi Syed,
The ToolWindowPane can be used to host WPF content or a Winform control.
For a Winform control, you just need to override the Window property get, and leave the Content property null.
For example:
public MyToolWindow() : base(null) { this.Caption = Resources.ToolWindowTitle; this.BitmapResourceID = 301; this.BitmapIndex = 1; control = new MyControl(); } override public IWin32Window Window { get { return (IWin32Window)control; } }
Sincerely,
Ed Dore
- Proposed As Answer by Ed DoreMicrosoft Employee, Moderator Friday, September 14, 2012 9:30 PM
- Marked As Answer by Ego JiangMicrosoft Contingent Staff, Moderator Monday, September 24, 2012 9:17 AM
-
Monday, September 24, 2012 9:18 AMModerator
Hi Syed,
I marked Ed's reply as answer.
Please unmark it, if it is not the answer.
Thank you for your understanding and support.
Best regards,
Ego [MSFT]
MSDN Community Support | Feedback to us
-
Monday, September 24, 2012 1:20 PMYes, it is. I should have done that myself. Sorry for being lazy and thanks for doing this.
Aziz ur Rahman http://www.dotnetpanda.com

