WPF:根据窗口大小自动调整ListView宽度

问题描述 投票:0回答:1

所以我在ListView里面有这个TabControl

<TabControl>
    <TabItem Width="70" Height="70" Margin="0,0,0,0">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="10"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="10"/>
            </Grid.ColumnDefinitions>
        <Grid Grid.Column="1">
        <Grid Grid.Row="1">
             <Grid.RowDefinitions>
                 <RowDefinition Height="Auto"/>
                 <RowDefinition Height="*"/>
                 <RowDefinition Height="Auto"/>
             </Grid.RowDefinitions>
         <Grid Grid.Row="1">
                 <ListView>
                     ...    
                 </ListView>
         </Grid>
         <Grid>
         </Grid>
         </Grid>
     </TabItem>
 </TabControl>

我的窗口ResizeMode是CanResizeWithGrip,当我调整我的应用程序时,我希望我的ListView根据我的Window宽度自动调整大小。

当我的应用程序宽度改变了我的ListView时,我尝试定义我的qazxsw poi qazxsw poi qazxsw poi。

wpf listview window-resize autoresize
1个回答
0
投票

我相信,因为你的HorizontalAlignment嵌套在其他控件中,那些控件需要将Stretch设置为ListView。我现在正打电话,所以当我回到家时,我会在我的系统上试用你的XAML,如果我发现别的东西是罪魁祸首,我会更新我的答案。

编辑:我已经将你的代码复制到VS中并为我正确拉伸。我没有任何内容要检查,但如果我设置

ListView

我可以看到,当我调整窗口大小时,控件实际上是拉伸的。现在我不确定你遇到的问题是什么。你有没有机会发布更多细节?

© www.soinside.com 2019 - 2024. All rights reserved.