【问题标题】:WPF ComboBox with checkboxes and textbox with search field show text box on scroll带有复选框的 WPF 组合框和带有搜索字段的文本框在滚动时显示文本框
【发布时间】:2018-08-17 13:10:25
【问题描述】:

如何在组合框中的弹出框滚动时显示文本框控件,这是WPF ComboBox with checkboxes and textbox with search field的延续

我还想在文本框和绑定的组合框项目之间显示一个行间距

<Popup 
Name="Popup"
Placement="Bottom"                        
AllowsTransparency="True" 
Focusable="False"  IsOpen="{TemplateBinding IsDropDownOpen}"
PopupAnimation="Slide">
<Grid 
    Name="DropDown"
    SnapsToDevicePixels="True"  
    MinWidth="{TemplateBinding ActualWidth}"
    MaxHeight="{TemplateBinding MaxDropDownHeight}">
    <Border 
        x:Name="DropDownBorder"
        BorderThickness="1" Background="White"
        BorderBrush="Black"/>
    <ScrollViewer Margin="4,6,4,6" SnapsToDevicePixels="True" DataContext="{Binding}">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <TextBox />
            <StackPanel Grid.Row="1" IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained" />
        </Grid>
    </ScrollViewer>
</Grid>

【问题讨论】:

  • 为 TextBox 设置 Margin
  • 你想让 TextBox 出现在滚动查看器的顶部吗?
  • 当我滚动时是的

标签: c# wpf


【解决方案1】:

尝试将ScrollViewer 放在与Grid 相同的Grid 中,但放在另一行中,例如:

<Popup 
    Name="Popup"
    Placement="Bottom"                        
    AllowsTransparency="True" 
    Focusable="False"  IsOpen="{TemplateBinding IsDropDownOpen}"
    PopupAnimation="Slide">
    <Grid 
        Name="DropDown"
        SnapsToDevicePixels="True"  
        MinWidth="{TemplateBinding ActualWidth}"
        MaxHeight="{TemplateBinding MaxDropDownHeight}">
        <Border 
            x:Name="DropDownBorder"
            BorderThickness="1" Background="White"
            BorderBrush="Black"/>
        <Grid Margin="4,6,4,6" SnapsToDevicePixels="True" DataContext="{Binding}">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <TextBox />
            <ScrollViewer Grid.Row="1">
                <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained" />
            </ScrollViewer>
        </Grid>
    </Grid>
</Popup>

【讨论】:

  • 不走运,我看不到总项目
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-06-15
  • 1970-01-01
  • 2019-05-12
  • 2012-12-22
  • 2015-08-10
相关资源
最近更新 更多