Specifying DataTemplate.DataType with a custom type extension

后端 未结 4 501
渐次进展
渐次进展 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:41

    I found a nasty workaround for this. For whatever reason, @Anvaka is right: the DataType property won't allow you to use a custom MarkupExtension. But it WILL allow you to use a StaticResource of the custom MarkupExtension.

    Take your MarkupExtension, add a public default constructor to it. Then create an instance of your extension in the resources, setting the properties directly. Boom, it takes it. The below is similar to what you would need to do

    
    
        
    
    

提交回复
热议问题