wpf - 水平排序列表框数据模板中的图像

标签 wpf silverlight datatemplate

预览

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/

相关文章:

wpf - 为什么这个数据模板在设计时不起作用?

wpf - 如何在多绑定(bind)字符串 block 中添加条件? (WPF)

asp.net - 大多数人如何在应用程序(子文件夹)中组织代码?

c# - 将 .net 4 类库中的 C# 类公开给 Silverlight App

wpf - 具有GridViewColumn和DataTemplate的WPF ListView

使用 DataTemplate 的 ListBox 的 WPF 双向绑定(bind)

c# - 如何对 ObservableCollection<KeyValuePair<int, string> 进行排序

wpf - MoonlightDesktop适合将wpf应用程序移植到Linux吗?

c# - 在 WPF 中将参数传递给 StartupUri

c# - 通过 Silverlight 4.0 的 VOIP 功能(最多 5 个用户的实时语音流)?