ItemTemplate with image

本文关键字:image with ItemTemplate | 更新日期: 2023-09-27 18:15:46

你好,我目前正在一个项目上工作,正在使用Listbox.ItemTemplate。我试图使模板看起来像这样:

      <ListBox.ItemTemplate>
            <DataTemplate>
                <Border BorderThickness="2" BorderBrush="Black" Margin="10" Width="100" Height="100" >
                //Image here//
                </Border>
            </DataTemplate>
        </ListBox.ItemTemplate>

问题是我在c#方法的帮助下手动添加项目。有人知道我是如何添加一个寺庙的项目如上所示?

ItemTemplate with image

如果您将模板添加到ListBox(如上所述),那么添加到列表框中的任何项都将应用该模板。该模板应用于列表框中的所有项。