开发者

Using System.Type in XAML

开发者 https://www.devze.com 2023-01-11 22:46 出处:网络
I need to be able to set a property of type System.Type in a UserControl. Im currently doing this: XAML:

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 开发者_StackOverflowXAML?


Use the x:Type Markup Extension:

<MyUserControl 
    xmlns:myns="clr-namespace:My.NameSpace"
    x:Name="TheControl"
    TheType="{x:Type myns:MyType}"/>
0

精彩评论

暂无评论...
验证码 换一张
取 消