首页 > 解决方案 > 滚动条可见时组合框底部的空白区域

问题描述

我注意到,当 WPF 组合框有足够的项目导致出现垂直滚动条(似乎是 18 个)时,水平滚动条也会出现空白区域。

带有空格的组合框

我猜水平滚动条是隐藏的而不是折叠的。有没有办法让它折叠或可见?

我认为这可能是我们代码中的一些晦涩风格,或者我们从数据库加载项目的方式或绑定有问题,但它仍然出现在一个新的测试项目中:

<Window x:Class="WpfComboScrollbar.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfComboScrollbar"
        mc:Ignorable="d"
        Title="MainWindow" Height="100" Width="150">
    <Grid>
        <StackPanel Margin="5">
            <ComboBox >
                <ComboBoxItem >Item1</ComboBoxItem>
                <ComboBoxItem >Item2</ComboBoxItem>
                <ComboBoxItem >Item3</ComboBoxItem>
                <ComboBoxItem >Item4</ComboBoxItem>
                <ComboBoxItem >Item5</ComboBoxItem>
                <ComboBoxItem >Item6</ComboBoxItem>
                <ComboBoxItem >Item7</ComboBoxItem>
                <ComboBoxItem >Item8</ComboBoxItem>
                <ComboBoxItem >Item9</ComboBoxItem>
                <ComboBoxItem >Item10</ComboBoxItem>
                <ComboBoxItem >Item11</ComboBoxItem>
                <ComboBoxItem >Item12</ComboBoxItem>
                <ComboBoxItem >Item13</ComboBoxItem>
                <ComboBoxItem >Item14</ComboBoxItem>
                <ComboBoxItem >Item15</ComboBoxItem>
                <ComboBoxItem >Item16</ComboBoxItem>
                <ComboBoxItem >Item17</ComboBoxItem>
                <ComboBoxItem >Item18</ComboBoxItem>
            </ComboBox>
        </StackPanel>
    </Grid>
</Window>

标签: wpfcomboboxscrollbar

解决方案


推荐阅读