【问题标题】:ListBox control not resizing when window is maximized窗口最大化时ListBox控件不调整大小
【发布时间】:2019-01-18 21:56:56
【问题描述】:

我还是 VS、C# 和 XAML 的新手。我在下面有这段代码

<Window x:Class="KANASoft___Xplora.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        WindowStartupLocation="CenterScreen" Icon="folder.gif" ResizeMode="CanResizeWithGrip"
        Title="KANASoft - Xplora" Height="700" Width="535" Background="Black" Name="mainWindow">
    <Grid Height="{Binding ElementName=mainWindow, Path=Height}" Width="{Binding ElementName=mainWindow, Path=Width}">
        <ListBox Background="Black" Name="LBHeader" BorderBrush="Aqua" ScrollViewer.HorizontalScrollBarVisibility="Disabled" BorderThickness="0 0 0 1" Height="80" VerticalAlignment="Top">
            <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <WrapPanel Orientation="Horizontal" Width="{Binding ElementName=mainWindow, Path=Width}"/>
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>
        </ListBox>
    </Grid>
</Window>

我希望我的&lt;ListBox Name="LBHeader"&gt; 在调整窗口大小时根据窗口的宽度调整大小,并且当我通过拖动窗口边缘调整窗口大小时它可以正常工作。 但问题是,当我最大化窗口时,&lt;ListBox Name="LBHeader"&gt; 不会随窗口调整大小。

我需要这方面的帮助。

【问题讨论】:

  • 您应该从GridWrapPanel 中删除Height and Width 属性。
  • @Fredy... 您的评论应该作为答案发布,它有效。虽然我没有删除 WrapPanel 的宽度
  • 谢谢,我把评论作为答案

标签: c# xaml


【解决方案1】:

您应该从GridWrapPanel 中删除Height and Width 属性。

【讨论】:

    【解决方案2】:

    我搜索了你,发现了这个: C# windows form for all screen size With resize Controls and Positioning 希望对你有帮助

    【讨论】:

      猜你喜欢
      • 2011-05-18
      • 1970-01-01
      • 2011-10-19
      • 2023-03-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-19
      相关资源
      最近更新 更多