包含列表作为项目的列表框的 DataTemplate 不会显示

发布于 2025-01-04 00:20:02 字数 583 浏览 4 评论 0原文

我有以下列表框项目的数据模板:

<DataTemplate x:Key="substanceListShower">
    <ListBox ItemsSource="{Binding Items}">
        <ItemsPanelTemplate>
            <StackPanel Orientation="Horizontal"/>
        </ItemsPanelTemplate>
    </ListBox>
</DataTemplate>

然后我像这样应用项目模板:

 ReactantInterfacesListBox.ItemTemplate = (DataTemplate)FindResource("substanceListShower");

但是在项目列表中我得到 ToString() 返回:

System.Windows.Controls.ItemsPanelTemplate

如有任何帮助,我们将不胜感激。

I have the following data template for a list box items:

<DataTemplate x:Key="substanceListShower">
    <ListBox ItemsSource="{Binding Items}">
        <ItemsPanelTemplate>
            <StackPanel Orientation="Horizontal"/>
        </ItemsPanelTemplate>
    </ListBox>
</DataTemplate>

And then I apply the item template like this:

 ReactantInterfacesListBox.ItemTemplate = (DataTemplate)FindResource("substanceListShower");

But in the list for the items i get a ToString() return:

System.Windows.Controls.ItemsPanelTemplate

Any help would be appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

月隐月明月朦胧 2025-01-11 00:20:02

您将 ItemsPanelTemplate 添加到 ListBox 中,但您的定义缺少用于设置属性的 ListBox.ItemsPanel 标记。

You add an ItemsPanelTemplate to your ListBox, your definition lacks the ListBox.ItemsPanel tags to set the property instead.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文