具有自动边距的网格 - Windows Phone 8.1 Silverlight
Grid With Auto Margin - Windows Phone 8.1 Silverlight
我有这个 XAML 代码,我希望网格位于第 2 行和第 1-3 列。
现在的问题是,如果我指定网格的边距,它在不同尺寸的设备上看起来不太好,如果我不指定边距,网格就会超出移动屏幕。
如何在布局内保持边距自动和网格
<Grid Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="3">
<Button x:Name="undoButton"
Content="undo"
Grid.Column="1" Grid.Row="2"
HorizontalAlignment="Left"
Click="undoButton_Click" Height="70" Width="90"
FontSize="16" Background="#FF4B9599" />
<Button x:Name="redoButton" Content="redo"
Height="70"
Width="90"
Grid.Column="2" Grid.Row="2"
HorizontalAlignment="Center"
Click="redoButton_Click" FontSize="16"
Background="#FF4B9599"/>
<Button x:Name="clearButton"
Content="clear"
HorizontalAlignment="Right"
Height="70" Width="90"
Grid.Column="3" Grid.Row="2"
FontSize="16" Background="#FF4B9599"
Click="clearButton_Click"/>
</Grid>
这里是行和列的定义:
<Grid.RowDefinitions>
<RowDefinition Height="90" />
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
不加margin就有格子
根据您提供给我们的信息,
解决方案非常简单
替换为:
<Grid.RowDefinitions>
<RowDefinition Height="90" />
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
有了这个:
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="90" />
</Grid.RowDefinitions>
如果您向我们提供有关所需结果的更多信息以及您希望放入第 0 行和第 1 行的其他项目,我们可以为您提供更具体的帮助。
我不知道问题是什么或出在哪里,但这有效
<RowDefinition Height="Auto" MinHeight="80"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto" MinHeight="70" />
我有这个 XAML 代码,我希望网格位于第 2 行和第 1-3 列。
现在的问题是,如果我指定网格的边距,它在不同尺寸的设备上看起来不太好,如果我不指定边距,网格就会超出移动屏幕。
如何在布局内保持边距自动和网格
<Grid Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="3">
<Button x:Name="undoButton"
Content="undo"
Grid.Column="1" Grid.Row="2"
HorizontalAlignment="Left"
Click="undoButton_Click" Height="70" Width="90"
FontSize="16" Background="#FF4B9599" />
<Button x:Name="redoButton" Content="redo"
Height="70"
Width="90"
Grid.Column="2" Grid.Row="2"
HorizontalAlignment="Center"
Click="redoButton_Click" FontSize="16"
Background="#FF4B9599"/>
<Button x:Name="clearButton"
Content="clear"
HorizontalAlignment="Right"
Height="70" Width="90"
Grid.Column="3" Grid.Row="2"
FontSize="16" Background="#FF4B9599"
Click="clearButton_Click"/>
</Grid>
这里是行和列的定义:
<Grid.RowDefinitions>
<RowDefinition Height="90" />
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
不加margin就有格子
根据您提供给我们的信息, 解决方案非常简单
替换为:
<Grid.RowDefinitions>
<RowDefinition Height="90" />
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
有了这个:
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="90" />
</Grid.RowDefinitions>
如果您向我们提供有关所需结果的更多信息以及您希望放入第 0 行和第 1 行的其他项目,我们可以为您提供更具体的帮助。
我不知道问题是什么或出在哪里,但这有效
<RowDefinition Height="Auto" MinHeight="80"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto" MinHeight="70" />