Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
众所周知,我们不能将 DataTemplates 与接口一起使用,但显然(老问题)我们可以使用抽象类。
为什么?
多重继承参数也适用于抽象类......
您提到的旧问题仍然将数据模板应用于具体类。如果您尝试将数据模板应用于抽象类,您将遇到同样的问题。没有什么能阻止您使用接口 - 您只需要将数据模板与该接口的具体实现相关联。
问题本质上是 WPF 使用运行时类型来解析模板。