Jas*_*Jas 3 c# silverlight datatemplate itemscontrol stackpanel
出于某种原因,在dataTemplate中添加的项目将不会执行我告诉他们要做的事情!
我试图将一些图像水平放置在一个堆叠面板中,但无论我如何尝试,它们只是垂直移动.
这是我的xaml.
<DataTemplate x:Name="View">
<Border BorderBrush="Red" BorderThickness="4" >
<StackPanel Orientation="Horizontal">
<ItemsControl ItemsSource="{Binding Path=_Collection, Mode=OneWay}" >
<ItemsControl.ItemTemplate>
<DataTemplate >
<Image Source="{Binding _Source}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<TextBlock Height="30" FontFamily="Trebuchet MS" FontSize="18" Text="{Binding _Name}" />
</StackPanel>
</Border>
</DataTemplate>
Run Code Online (Sandbox Code Playgroud)
一切都很好.这是从用户控件内部调用的
<ItemsControl ItemTemplate="{StaticResource siteView}" ItemsSource="{Binding Path=_SiteDisplay"/>
Run Code Online (Sandbox Code Playgroud)
我的obervable集合_SiteDisplay包含另一个名为_Collection的oberservable集合,它保存图像的url.
这是从实际代码中删除的,但说明了问题.我不能让图像水平对齐!非常感谢任何帮助 - 或建议更好的方法.
Cod*_*ked 12
您需要更改ItemsControl使用的面板,而不是包含ItemsControl的面板:
<ItemsControl ItemsSource="{Binding Path=_Collection, Mode=OneWay}" >
<ItemsControl.ItemTemplate>
<DataTemplate >
<Image Source="{Binding _Source}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate >
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6770 次 |
| 最近记录: |