How to Automatically Use a DataTemplate Based on ContentControl's Current Content's DataType

后端 未结 2 1818
说谎
说谎 2020-12-15 03:58

When I attempt to specify multiple DataTemplates for use by a ContentControl so that the correct one (based on Type) is used, I end up with Content that is simply the Conten

相关标签:
2条回答
  • 2020-12-15 04:30

    The x:Type bit should be between curly braces {}:

    <DataTemplate DataType="{x:Type vm:TypeAViewModel}">
    
    0 讨论(0)
  • 2020-12-15 04:47

    x:Type is a MarkupExtension, which requires {} to indicate to the XAML compiler.

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