Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
带有网格和按钮的XAML页面_Xaml_Xamarin_Xamarin.forms - Fatal编程技术网

带有网格和按钮的XAML页面

带有网格和按钮的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

我有一个网格,它将占据我的Xamarin.Forms页面的大部分,我想在网格下面添加一个按钮。我的问题是,我使用下面的语法来添加按钮,但是按钮填充了整个页面

我需要更改什么,使按钮直接显示在网格下方

    <?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>