gpt4 book ai didi

wpf - 使用主题后列表框不水平显示项目

转载 作者:行者123 更新时间:2023-12-04 21:15:03 26 4
gpt4 key购买 nike

我使用列表框作为我的菜单项持有者,通过使用

            <ListBox.ItemsPanel>

<ItemsPanelTemplate>

<VirtualizingStackPanel Orientation="Horizontal" />

<WrapPanel></WrapPanel>

</ItemsPanelTemplate>

</ListBox.ItemsPanel>

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

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

问候,

最佳答案

我们在 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"/>

你应该可以开始了。

关于wpf - 使用主题后列表框不水平显示项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4244793/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com