开发者

Generic Type XAML 2009

开发者 https://www.devze.com 2023-04-07 08:52 出处:网络
I have a litte problems with these class public class MyClass : MyGenericClass<String, Int32> { } // XAML Class

I have a litte problems with these class

public class MyClass : MyGenericClass<String, Int32>
{

}

// XAML Class
public class MyGenericClass<开发者_如何学JAVAT, U> : MyGenericClassBase<T, U>
    where U : class
    where T : class
{
    public MyGenericClass()
    {
        InitializeComponent();
    }
}

public class MyGenericClassBase<T, U>
    where U : class, new()
    where T : class, new()
{
    T _t;
    U _u;
    public MyGenericClassBase()
    {

    }
}

I want to did the class "MyGenericClass" in XAML but I can't !

I try it :

<MyGenericClassBase x:Class="MyGenericClass"  
         x:TypeArguments="class,class"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >

       ...

How can i pass the argument type at my "MyGenericClass" and the inherit class "MyGenericClassBase "

Thanks a lot

Nico


XAML 2006: You can't use generic types in xaml 2006. The easiest solution is to use MyClass directly. Check out this question for other workarounds: Can I specify a generic type in XAML (pre .NET 4 Framework)?

XAML 2009: Generic types are supported natively:

<MyGenericClass x:TypeArguments="x:Int32, x:String"> 
    ...
</MyGenericClass>
0

精彩评论

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

关注公众号