我无法将我的内部网格的一部分缩放到特定大小。问题是,我想做的是在一个地方周围创建一个边框,稍后我将在其中插入图像。我希望我的应用程序具有可扩展性,但目前我无法创建它。
所以,这是我的代码:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition Height="100" />
<RowDefinition Height="200*" />
<RowDefinition Height="50" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50" />
<ColumnDefinition Width="100*" />
<ColumnDefinition Width="100*" />
<ColumnDefinition Width="50" />
</Grid.ColumnDefinitions>
<Button Grid.Row="0" Grid.Column="0"
Style="{StaticResource ReturnBackButtonStyle}"
Command="{Binding ReturnFromSearchingCommand, Mode=OneWay}" />
<TextBlock Grid.Row="1" Grid.Column="1"
Text="Game"
FontSize="48"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
<TextBlock Grid.Row="1" Grid.Column="2"
Text="Controls"
FontSize="48"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
<Canvas Grid.Row="2" Grid.Column="1"
Background="LightBlue"
Name="MyCanvas"
Focusable="True">
<Grid ShowGridLines="True">
<Grid.RowDefinitions>
<RowDefinition Height="100" />
<RowDefinition Height="auto" />
<RowDefinition Height="50" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50" />
<ColumnDefinition />
<ColumnDefinition Width="50" />
</Grid.ColumnDefinitions>
/* .. Mouse triggers .. */
<Canvas Grid.Row="0" Grid.Column="0">
<Label Name="MashKey" Content="Current key to Mash: NONE" FontSize="18" FontWeight="Bold" Foreground="White"/>
</Canvas>
<Canvas Grid.Row="0" Grid.Column="2">
<Label Background="Red" Name="MashedCount" Content="Last Mash Count: 0" FontSize="18" FontWeight="Bold" Canvas.Right="0" Foreground="White"/>
</Canvas>
<Canvas Background="Black" IsHitTestVisible="False" Grid.Column="1" Grid.Row="1"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
>
<Viewbox StretchDirection="DownOnly" >
<Rectangle Fill="Red"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Width="auto"
Height="auto" ></Rectangle>
</Viewbox>
</Canvas>
</Grid>
</Canvas>
<DockPanel Grid.Row="2" Grid.Column="2">
/* ... the right side of the first Grid ... works fine for now .. */
</DockPanel>
</Grid>
外部网格工作得非常好,即使是“画布右”。但不幸的是,我无法使第二个网格的中间部分扩大到其最大潜力。知道我该怎么做吗?先感谢您!