【发布时间】:2011-09-14 00:24:32
【问题描述】:
我正在尝试使用数据模板将图像的源绑定到列表框中的字符串。
当我运行应用程序时,我在浏览器中看到了图像,但在设计图面上看不到它。
有什么想法吗?
我创建了一个带有 3 行网格的示例用户控件。 在第 0 行我只是把图像 在第 1 行中,我将图像放入列表框项 在第 2 行中,我将图像放入绑定到资源的列表框中的数据模板中
在设计图面上,我可以在第 0 行和第 1 行看到图像,但在第 2 行看不到。
public class PersonCollection : List<Person>
{
}
public class Person
{
public string Name { get; set; }
public string PictureURL { get; set; }
}
<Grid x:Name="LayoutRoot" Background="White">
<Grid.Resources>
<mystuff:PersonCollection x:Key="PersonList">
<mystuff:Person Name="Rick" PictureURL="abc.jpg"/>
<mystuff:Person Name="Bob" PictureURL="abc.jpg"/>
</mystuff:PersonCollection>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Image Source="abc.jpg"/>
<ListBox Grid.Row="1">
<ListBoxItem>
<StackPanel Orientation="Horizontal">
<Image Source="abc.jpg"/>
</StackPanel>
</ListBoxItem>
</ListBox>
<ListBox Grid.Row="2" ItemsSource="{StaticResource PersonList}">
<ListBox.ItemTemplate>
<DataTemplate>
<Image Source="{Binding PictureURL}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
【问题讨论】:
-
我说的设计师是VS Web Developer Express SP1 IDE,不是blend
标签: silverlight image binding datatemplate designer