Uzi
Uzi

Reputation: 41

Visual Studio 2010: using a winforms user control in a VSPackage Tool Window

when creating a simple VSPackage with a Tool Window a sample WPF user control is created and added to the Tool Window. Must this user control be of WPF? i have a winforms user control and, when adding it to the tool window it's not getting displayed. tried hosting it in WPF with no success. is there any standard way of doing this?

Upvotes: 4

Views: 838

Answers (2)

Syed Aziz ur Rahman
Syed Aziz ur Rahman

Reputation: 41

I faced the same issue. Searched a lot. Was not able to find the answer or sample. Finally posted on msdn forum. Got my answer. Here is the link to the thread of msdn forum

MSDN Forum thread link

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 System.Windows.Forms.IWin32Window Window
    {
        get
        {
            return (System.Windows.Forms.IWin32Window)control;
        }
    }

Upvotes: 4

Ian
Ian

Reputation: 34529

I'm almost certain it can be winforms too, and I'm sure there's a demo somewhere on MSDN. I'll see if I can dig it up sometime.

Upvotes: 0

Related Questions