开发者

ListBox not showing items horizontally after using theme

开发者 https://www.devze.com 2023-01-26 21:08 出处:网络
I am using a listbox as my Menu items holder, by using <ListBox.ItemsPanel> <ItemsPanelTemplate>

I am using a listbox as my Menu items holder, by using

            <ListBox.ItemsPanel>

                <ItemsPanelTemplate>

                    <VirtualizingStackPanel Orientation="Horizontal" />

                    <WrapPanel></WrapPanel>

                </ItemsPanelTe开发者_开发知识库mplate>

            </ListBox.ItemsPanel>

i can show all my items horizontally in listbox but whenever i use any theme it started showing items vertically (I am using Microsoft's ExpressionLight.xaml in my project's Application.xaml)

Any solution, even if how to stop my listbox (only this one) using theme.

Regards,


We had the same problem with ExpressionDark and discovered it was a problem in the Style.

To fix simply modify the ListBox ControlTemplate (Line 710 in ExpressionDark.xaml for us):

<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>
    ...

Change the StackPanel to an ItemsPresenter:

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

And you should be good to go.


I'd guess the theme has a default setting for orientation which overwrites your settings?

0

精彩评论

暂无评论...
验证码 换一张
取 消