【发布时间】:2018-01-22 20:51:30
【问题描述】:
我正在尝试将我的本机 Xamarin.iOS 转换为 Xamarin.Forms,并努力解决一个简单的布局问题。我想要实现的是像这样的红色网格菜单:
所以每个 Gridelement 的 height 应该 equal width 但我得到的只是这个:
我的 Xaml 如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<mvvm:BaseContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:mvvm="clr-namespace:SharpLibrary.Forms.Source.MVVM;assembly=SharpLibrary.Forms"
xmlns:cc="clr-namespace:Gorilla.Forms.Source.UI.CustomControls"
x:Class="Gorilla.Forms.Source.UI.Guest.GuestMainPage">
<ContentPage.Content>
<RelativeLayout
VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand"
>
<Image Style="{StaticResource StandardBackgroundImage}" />
<ScrollView
RelativeLayout.WidthConstraint = "{ConstraintExpression Type=RelativeToParent, Property=Width}"
RelativeLayout.HeightConstraint = "{ConstraintExpression Type=RelativeToParent, Property=Height}"
>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<cc:GridMenuItem
x:Name="testBox"
Grid.Row="0" Grid.Column="0"
BackgroundColor="Red"
Title="Test"
Icon="Text" />
<Frame
x:Name="testFrame"
Grid.Row="0" Grid.Column="1"
BackgroundColor="Gray"
HeightRequest="{Binding WidthRequest}">
<Label Text="gdjfgzhg" />
</Frame>
</Grid>
</ScrollView>
</RelativeLayout>
</ContentPage.Content>
</mvvm:BaseContentPage>
我不知道我做错了什么,我还发现了一些Threads,人们希望实现与我相同的目标,但它并没有达到我的预期。
希望有人知道答案
【问题讨论】:
标签: c# xamarin.forms xamarin.ios