Implicit DataTemplate doesn't work

隐身守侯 提交于 2019-12-01 03:57:14

DataType requires the use of x:Type as the property's type is Object, so if you type DataType="ns:Type" you set it to the string "ns:Type". If the property's type were Type (as with Style.TargetType for example) the XAML processor would automatically convert that string to a Type.

Thus here you should write:

  <DataTemplate DataType="{x:Type vm:ProductListViewModel}">
    <v:ProductListView/>
  </DataTemplate>

(The property type is Object to allow data-templating of XML data, see the documentation for more information on that)

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!