我需要在Frame
或Button
内显示一个小图像,但是Image
所使用的图像要比我的Button
/ Frame
大,何时我尝试使用Frame
来做到这一点,它仅显示Image
不会显示Button
,问题是Image
太大了。我该如何解决。
使用Button
:
<Frame BackgroundColor="#40000000" BorderColor="#FFFFFF" CornerRadius="6" Padding="0" Grid.Row="1" Grid.Column="1">
<Grid>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="0.01*"/>
<RowDefinition Height="0.15*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.01*"/>
<ColumnDefinition Width="0.15*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button Image="sobremesa.png" BackgroundColor="Black" Grid.Row="1" Grid.Column="1" x:Name="Ingredient"/>
</Grid>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="0.2*"/>
<RowDefinition Height="2.8*"/>
<RowDefinition Height="0.7*"/>
<RowDefinition Height="0.7*"/>
<RowDefinition Height="0.2*"/>
</Grid.RowDefinitions>
<Image Source="https://i.imgur.com/066Iazn.png" Grid.Row="1" x:Name="CategoryImage"/>
<Label Text="Melão c/ Presunto" VerticalTextAlignment="Start" TextColor="White" HorizontalTextAlignment="Center" Grid.Row="2"/>
<Label Text="6.90€" VerticalTextAlignment="Start" TextColor="White" HorizontalTextAlignment="Center" Grid.Row="3"/>
</Grid>
</Grid>
<Frame.GestureRecognizers>
<TapGestureRecognizer
Tapped="TapGestureRecognizer_Tapped"
NumberOfTapsRequired="1"/>
</Frame.GestureRecognizers>
</Frame>
使用Frame
:
<Frame BackgroundColor="#40000000" BorderColor="#FFFFFF" CornerRadius="6" Padding="0" Grid.Row="1" Grid.Column="1">
<Grid>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="0.01*"/>
<RowDefinition Height="0.15*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.01*"/>
<ColumnDefinition Width="0.15*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Frame Grid.Row="1" Grid.Column="1" BackgroundColor="Black" x:Name="Ingredient">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="0.1*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="0.1*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.1*" />
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="0.1*"/>
</Grid.ColumnDefinitions>
<Image Source="sobremesa.png" Grid.Row="1" Grid.Column="1"/>
</Grid>
</Frame>
</Grid>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="0.2*"/>
<RowDefinition Height="2.8*"/>
<RowDefinition Height="0.7*"/>
<RowDefinition Height="0.7*"/>
<RowDefinition Height="0.2*"/>
</Grid.RowDefinitions>
<Image Source="https://i.imgur.com/066Iazn.png" Grid.Row="1" x:Name="CategoryImage"/>
<Label Text="Melão c/ Presunto" VerticalTextAlignment="Start" TextColor="White" HorizontalTextAlignment="Center" Grid.Row="2"/>
<Label Text="6.90€" VerticalTextAlignment="Start" TextColor="White" HorizontalTextAlignment="Center" Grid.Row="3"/>
</Grid>
</Grid>
<Frame.GestureRecognizers>
<TapGestureRecognizer
Tapped="TapGestureRecognizer_Tapped"
NumberOfTapsRequired="1"/>
</Frame.GestureRecognizers>
</Frame>
我试图显示在Image
中的Frame
在子Frame
中。
请记住,当我尝试使用Frame
显示时,它不会显示Image
。