A A
RSS

How to add a User Control to your WPF Window

Fri, Mar 9, 2007

Uncategorized

In the window XAML add the namespace of your control. So, if your control is called MyControl and your project is called MyProj then most likely the full namespace is MyProj.MyControl.

The control might look like this:

<UserControl
x:Class=MyControl


xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation


xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml>

    <DockPanel>

        <Button>Test</Button>

        <Button>Test</Button>

        <Button>Test</Button>

        <Button>Test</Button>

    </DockPanel>

</UserControl>

 

Your form header will look like this:

<Window
x:Class=Window1


xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation


xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml

    xmlns:l=clr-namespace:MyProj


Title=wpf
Height=300
Width=300

>

Then to use the control you will do this:

<l:MyControl></l:MyControl>

I got this to work in VS 2005 with WPF Extensions but I cannot get it to work in Orcas March CTP… The project compiles and runs fine in both cases, but the control will just not show up in the Orcas version!!! Any ideas?

Tags:

Comments are closed.

Advertise Here
The Most Intelligent Add-In To Visual Studio Happy fan of

What I'm Doing...

Yonkly Open Source

Sign up for my newsletter




* = required field

powered by MailChimp!

megree Widget

Apparently, I am connected to Obama. Check this out...
My path to Obama

Cyber Identity