tags:

views:

10

answers:

1

I need to be able to set a property of type System.Type in a UserControl. Im currently doing this:

XAML:

<MyUserControl x:Name="TheControl"/>

Code behind:

TheControl.TheType = typeof(My.NameSpace.MyType);

Im looking to be able to do this (XAML only):

<MyUserControl x:Name="TheControl" TheType="??"/>

Is there a way to use typeof inside XAML?

+2  A: 

Use the x:Type Markup Extension:

<MyUserControl 
    xmlns:myns="clr-namespace:My.NameSpace"
    x:Name="TheControl"
    TheType="{x:Type myns:MyType}"/>
Quartermeister
Exactly what I was looking for, thank you! (+1 for linking to relevant docs)
mizipzor