我試圖將圖像的源代碼綁定到帶有數據模板的列表框中的字符串。Silverlight 4:datatemplate中的圖像未出現在設計圖面
當我運行該應用程序時,我在瀏覽器中看到圖像,但在設計圖面上看不到它。
任何想法?
我用3行網格創建了一個示例用戶控件。 在0行i只是把圖像 在行1我把圖像劃分爲列表框項目 在第2行我把圖像劃分成一個DataTemplate在綁定到資源
在設計表面上的列表框,我可以見行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速成SP1 IDE,而不是混合 – 2011-06-13 20:32:49