在代码中创建数据模板
var template = new FuncDataTemplate<Student>((value, namescope) =>
new TextBlock
{
[!TextBlock.TextProperty] = new Binding("FirstName"),
});<DataTemplate DataType="{x:Type local:Student}">
<TextBlock Text="{Binding FirstName}"/>
</DataTemplate>示例
Last updated