ListBox/ListView 等控件的默认 ItemTemplate

use*_*697 4 .net wpf xaml

我在哪里可以找到/ItemTemplate等控件的默认值?MSDN 中没有关于此的任何内容。ListBoxListView

<ListBox.ItemTemplate>
    <DataTemplate>
        <!--What's the default value of this?-->
    </DataTemplate>
</ListBox.ItemTemplate>
Run Code Online (Sandbox Code Playgroud)

Saj*_*ran 5

来自WPF 教程

数据模板为您提供了一个非常灵活和强大的解决方案,用于替换 ListBox、ComboBox 或 ListView 等控件中数据项的视觉外观。

如果未指定数据模板,WPF 将采用仅是 TextBlock 的默认模板。

即默认值应该是:

<ListBox.ItemTemplate>
    <DataTemplate>
        <TextBlock Text="{Binding}"/>
    </DataTemplate>
</ListBox.ItemTemplate>
Run Code Online (Sandbox Code Playgroud)

阅读更多 DataTemplate