Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/silverlight/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Silverlight 在XAML中的ListBoxItem中放置图像_Silverlight_Xaml - Fatal编程技术网

Silverlight 在XAML中的ListBoxItem中放置图像

Silverlight 在XAML中的ListBoxItem中放置图像,silverlight,xaml,Silverlight,Xaml,我想知道是否可以将图像添加到xaml中的ListBoxItem中。 我试着这样做: <ListBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <Image Source="{Binding ImagePath}"></Image> <TextBlock T

我想知道是否可以将图像添加到xaml中的ListBoxItem中。 我试着这样做:

<ListBox.ItemTemplate>
      <DataTemplate>
          <StackPanel Orientation="Horizontal">
             <Image Source="{Binding ImagePath}"></Image>
             <TextBlock Text="{Binding Name}"></TextBlock>
        </StackPanel>
      </DataTemplate>
   </ListBox.ItemTemplate>


它确实有效,但我想看看是否有其他方法不使用模板。

我想不出更好的方法。为什么不希望使用该模板?

该列表用于显示选项,并且是固定的,因此,我希望看到不必在代码后面执行操作的替代方法。您可以始终在列表框中对项目进行硬编码:
谢谢您给了我这样一个想法,这正是我想要的: