预览
alt text http://img39.imageshack.us/img39/5466/howtoorderhorizontal.jpg
在突出显示的项目上,即使我已经使用<StackPanel Orientation="Horizontal">
,图像仍然垂直排序。 。我错过了什么吗?
我不希望图像具有 ListBoxItem 行为(悬停/单击)。我添加了IsEnabled="False"
到列表框,但图像的不透明度降低了:(你知道如何做这件事吗?
数据模板
<!-- FacilityTreeView data template -->
<telerik:HierarchicalDataTemplate x:Key="FecilityTemplate" ItemsSource="{Binding Facilities}">
<StackPanel Orientation="Horizontal">
<ListBox ItemsSource="{Binding Icons}" BorderThickness="0" Background="Transparent">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Source="{Binding Source}" Margin=" 0,0,2,0" ToolTipService.ToolTip="{Binding Tooltip}" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<TextBlock Text="{Binding Description}" VerticalAlignment="Center" />
</StackPanel>
</telerik:HierarchicalDataTemplate>
最佳答案
通过使用 ItemsPanelTemplate。
<ListBox.ItemTemplate>
<DataTemplate>
<Image Source="{Binding Source}" Margin=" 0,0,2,0" ToolTipService.ToolTip="{Binding Tooltip}" />
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ListBox.ItemsPanelTemplate>
关于wpf - 水平排序列表框数据模板中的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3211409/