DataTemplates and generic types

前端 未结 1 1019
心在旅途
心在旅途 2021-01-22 15:08

I have a generic class

public abstract class BaseViewModel

Since I am trying to create a DataTemplate that will be applied to all clas

相关标签:
1条回答
  • 2021-01-22 15:21

    I would create a non-generic version of BaseViewModel and let the generic one inherit from it:

    public abstract class BaseViewModel
    {
        // members that are not T-specific, if any
        // (not required, but could prove useful)
    }
    
    public abstract class BaseViewModel<T> : BaseViewModel
    {
        // T-specific members
    }
    

    By doing this, your DataTemplate is going to work.

    0 讨论(0)
提交回复
热议问题