[英]Improved presentation and punctuation
我在网格内有一个网格。 无论窗口大小如何,我都希望它可以使用最大大小:
但实际上并非如此,我无法找到原因。 这是代码:
<Window x:Class="SocialNetworkingApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Background="White" WindowStyle="None" HorizontalAlignment="Stretch" WindowState="Normal" AllowsTransparency="True" WindowStartupLocation="CenterScreen">
<Border Margin="0,0,0,0" BorderBrush="Black" BorderThickness="1,1,1,1" >
<Grid x:Name="Main_Grid" Background="White" Width="Auto" Height="Auto" Margin="0,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Top">
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition Height="25"/>
<RowDefinition Height="50"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="20"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Grid Name="Title_Bar" Grid.Row="0" VerticalAlignment="Top" ShowGridLines="True" Grid.IsSharedSizeScope="True" MouseDown="Drag_Window" Background="#FF4FA2DA" HorizontalAlignment="Left" Width="766" Height="31">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="120" />
</Grid.ColumnDefinitions>
</Grid>
</Grid>
</Border>
</Window>
通过最小化属性来解决
<Window x:Class="SocialNetworkingApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Background="White" WindowStyle="None" WindowState="Normal" AllowsTransparency="True" WindowStartupLocation="CenterScreen">
<Border Margin="0,0,0,0" BorderBrush="Black" BorderThickness="1,1,1,1" >
<Grid x:Name="Main_Grid" Background="White" >
<Grid.RowDefinitions>
<RowDefinition Height="10" />
<RowDefinition Height="20"/>
<RowDefinition Height="40"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="20"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Grid Name="Title_Bar" Grid.Row="0" Height="Auto" Background="#FF4FA2DA" >
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="120" />
</Grid.ColumnDefinitions>
</Grid>
</Grid>
</Border>
</Window>
<Grid Name="Title_Bar" Grid.Row="0" ... Width="766" Height="31">
如果要自动调整宽度,请不要指定宽度。 只需删除该属性。
编辑:以及删除HorizontalAlignment="Left"
设置器。 至少对于外部网格。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.