Specifying DataTemplate.DataType with a custom type extension

后端 未结 4 598
渐次进展
渐次进展 2021-01-05 00:01

I have this markup extension

public class NullableExtension : TypeExtension
{
    public NullableExtension() {
    }

    public NullableExtension( string ty         


        
4条回答
  •  既然无缘
    2021-01-05 00:48

    The syntax

    DataType="{x:Type TypeName=System:Nullable`1[[System.Int32]]}">
    

    doesn't seem to work for user defined types :(

    Actually one other way is to create a base non-generic type. Set first data template to that type and bind ContentPresenter.Content to the property which holds object of T. Then create other data templates for whatever T.

提交回复
热议问题