ListBox在使用主题后不水平显示项目

时间:2010-11-22 11:10:47

标签: wpf

我使用

将列表框用作我的菜单项持有者
            <ListBox.ItemsPanel>

                <ItemsPanelTemplate>

                    <VirtualizingStackPanel Orientation="Horizontal" />

                    <WrapPanel></WrapPanel>

                </ItemsPanelTemplate>

            </ListBox.ItemsPanel>

我可以在列表框中水平显示我的所有项目,但每当我使用任何主题时,它都会开始垂直显示项目(我在我的项目中使用Microsoft的ExpressionLight.xaml&#39的Application.xaml)

任何解决方案,即使如何使用主题停止我的列表框(只有这一个)。

此致

2 个答案:

答案 0 :(得分:8)

我们在ExpressionDark遇到了同样的问题,并发现它是Style中的一个问题。

要修复,只需修改ListBox ControlTemplate(ExpressionDark.xaml中的第710行):

<ControlTemplate TargetType="{x:Type ListBox}">
    <Grid>
        <Border x:Name="Border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2" Background="{DynamicResource ControlBackgroundBrush}" />
        <ScrollViewer Margin="1" Style="{DynamicResource NuclearScrollViewer}" Focusable="false" Background="{x:Null}">
            <StackPanel Margin="1,1,1,1" IsItemsHost="true" />
        </ScrollViewer>
    </Grid>
    ...

将StackPanel更改为ItemsPresenter:

<ItemsPresenter Margin="1,1,1,1"/>

你应该好好去。

答案 1 :(得分:1)

我猜主题有一个默认的方向设置会覆盖你的设置吗?

相关问题