带有网格和按钮的XAML页面
我有一个网格,它将占据我的Xamarin.Forms页面的大部分,我想在网格下面添加一个按钮。我的问题是,我使用下面的语法来添加按钮,但是按钮填充了整个页面 我需要更改什么,使按钮直接显示在网格下方带有网格和按钮的XAML页面,xaml,xamarin,xamarin.forms,Xaml,Xamarin,Xamarin.forms,我有一个网格,它将占据我的Xamarin.Forms页面的大部分,我想在网格下面添加一个按钮。我的问题是,我使用下面的语法来添加按钮,但是按钮填充了整个页面 我需要更改什么,使按钮直接显示在网格下方 <?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schem
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="XF.Pages.AEI" >
<ContentView Content="{Binding ApprovedUserGrid,Mode=TwoWay}" Padding="0,30,0,0"/>
<Button Command="{Binding OkayCommand}" Text="Okay" TextColor="White"
FontAttributes="Bold" FontSize="Large" HorizontalOptions="FillAndExpand"
BackgroundColor="#088da5" />
</ContentPage>
编辑我编辑的代码是这样读的,没有错误,但是我在页面上没有看到我的按钮
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="XF_Login.Pages.ApproveUsers" >
<StackLayout Orientation="Vertical" Padding="30" Spacing="40">
<ContentView Content="{Binding ApprovedUserGrid,Mode=TwoWay}" Padding="0,30,0,0"/>
<Button Command="{Binding OkayCommand}" Text="Okay" TextColor="White"
FontAttributes="Bold" FontSize="Large" HorizontalOptions="FillAndExpand"
BackgroundColor="#088da5" />
</StackLayout>
</ContentPage>
网格在哪里??也许你试图创建一个自定义控件,却混淆了用contentpage而不是contentview来包装它?@NickKovalsky-i edit OP来显示网格的创建。如果我需要将数据绑定到网格的实际位置包括在内,我也可以这样做。仍然看不到网格和按钮的布局位置。您只显示了控件,而没有显示布局控件的页面或代码。ContentPage只能有一个子项。你需要把你的网格和按钮放在一个布局容器里。当有其他有趣的事情发生时,如果没有看到你所有的布局,很难说出它是什么。
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="XF_Login.Pages.ApproveUsers" >
<StackLayout Orientation="Vertical" Padding="30" Spacing="40">
<ContentView Content="{Binding ApprovedUserGrid,Mode=TwoWay}" Padding="0,30,0,0"/>
<Button Command="{Binding OkayCommand}" Text="Okay" TextColor="White"
FontAttributes="Bold" FontSize="Large" HorizontalOptions="FillAndExpand"
BackgroundColor="#088da5" />
</StackLayout>
</ContentPage>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="XF_Login.Pages.ApproveUsers" >
<StackLayout Orientation="Vertical" VerticalOptions="FillAndExpand" Padding="30" Spacing="40">
<ContentView VerticalOptions="FillAndExpand" Content="{Binding ApprovedUserGrid,Mode=TwoWay}" Padding="0,30,0,0"/>
<Button Command="{Binding OkayCommand}" Text="Okay" TextColor="White"
FontAttributes="Bold" FontSize="Large" HorizontalOptions="Center"
BackgroundColor="#088da5" />
</StackLayout>
</ContentPage>