搜索过滤器时,列表视图位于顶部

时间:2018-11-29 04:41:56

标签: wpf listview gridview

我有一个列表视图和搜索过滤器,一旦我开始使用搜索过滤,列表视图就会缩小并集中在中心(请查看图片的前后)

Before After

我需要至少将列表视图保持在顶部。我试图申请 在XAML中,verticalAlignment =“ Top”,但它不起作用。我尝试在XAML Listview上应用Height,它可以工作,但是请考虑我有全屏选项,并且listview需要响应。如果我应用了固定的高度,它将固定在窗口的不同方面。

这是代码

<ListView x:Name="Foundation" VerticalAlignment="Top" HorizontalAlignment="Left" Height="800">          
        <ListView.View>
            <GridView>
                <GridView.ColumnHeaderContainerStyle>
                    <Style TargetType="{x:Type GridViewColumnHeader}">
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type GridViewColumnHeader}">
                                    <Border BorderThickness="0,0,0,1" BorderBrush="White" Background="Transparent">
                                        <TextBlock x:Name="ContentHeader" Text="{TemplateBinding Content}" Padding="5,5,5,0" Width="{TemplateBinding Width}" TextAlignment="Center" />
                                    </Border>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                        <Setter Property="OverridesDefaultStyle" Value="True" />
                        <Setter Property="Foreground" Value="#FF4F2727" />
                        <Setter Property="FontSize" Value="18" />
                    </Style>
                </GridView.ColumnHeaderContainerStyle>
                <GridViewColumn
                        DisplayMemberBinding="{Binding ControlCode}"
                        Header="Control Code" />
                <GridViewColumn
                        DisplayMemberBinding="{Binding ORNo}"
                        Header="OR No." />
                <GridViewColumn
                        DisplayMemberBinding="{Binding ORDate, StringFormat=d}"
                        Header="OR Date" />
                <GridViewColumn
                        DisplayMemberBinding="{Binding RefName}"
                        Header="Ref Name" />
                <GridViewColumn
                        DisplayMemberBinding="{Binding TotalAmount}"
                        Header="Amount" />
            </GridView>
        </ListView.View>
    </ListView>

0 个答案:

没有答案