Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.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
C# 如何在xamarin forms应用程序中使网格导航栏位于列表视图的右下方_C#_Xamarin_Xamarin.forms - Fatal编程技术网

C# 如何在xamarin forms应用程序中使网格导航栏位于列表视图的右下方

C# 如何在xamarin forms应用程序中使网格导航栏位于列表视图的右下方,c#,xamarin,xamarin.forms,C#,Xamarin,Xamarin.forms,您好,我正在使用xamarin表单开发一个应用程序,我的主屏幕UI如下所示: 如何让导航条正好位于抽认卡下方 以下是我的xaml代码: <?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="AppName.Ap

您好,我正在使用xamarin表单开发一个应用程序,我的主屏幕UI如下所示:

如何让导航条正好位于抽认卡下方

以下是我的xaml代码:

<?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="AppName.AppNameHome">
  <Grid RowSpacing="0" ColumnSpacing="0">
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
    <ListView x:Name="listView" HasUnevenRows="true"  ItemSelected="OnItemSelected"> Grid.Row="0" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
    <ListView.ItemTemplate>
      <DataTemplate>
        <ViewCell>
          <Frame Padding="0,0,0,8" BackgroundColor="#d2d5d7">
            <Frame.Content>
              <Frame Padding="15,15,15,15"   OutlineColor="Gray" BackgroundColor="White">
                <Frame.Content>
                  <StackLayout Padding="20,0,0,0"  Orientation="Horizontal">

                    <Image
                            HorizontalOptions="Start"
                            Source="{Binding Image}"/>
                    <Label 
                           HorizontalOptions="CenterAndExpand"
                           Text="{Binding Name}"
                           FontFamily="OpenSans-Light"
                           FontSize="24"/>
                  </StackLayout>
                </Frame.Content>
              </Frame>
            </Frame.Content>
          </Frame>
        </ViewCell>
      </DataTemplate>
    </ListView.ItemTemplate>
  </ListView>
  <Grid Grid.Row="1" BackgroundColor="#eff3f6" Padding="0,0,0,0">
          <Grid.ColumnDefinitions>
          <ColumnDefinition Width="*"/>
          <ColumnDefinition Width="*"/>
          <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
          <StackLayout Orientation="Horizontal"  VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
              <Button  Grid.Row="0" Grid.Column="1" Image="books.png" HorizontalOptions="CenterAndExpand" BackgroundColor="Transparent" Clicked="OpenBooks" />
              <Button  Grid.Row="0" Grid.Column="2"  HorizontalOptions="EndAndExpand" BorderColor="Transparent" BackgroundColor="Transparent" Clicked="gotosettings" />
          </StackLayout>
        </Grid>
    </Grid>
</ContentPage>

Grid.Row=“0”VerticalOptions=“FillAndExpand”HorizontalOptions=“FillAndExpand”>
编辑以下是我的c#代码:

使用系统;
使用System.Collections.Generic;
使用AppName.Math;
使用Xamarin.Forms;
使用Plugin.Messaging;
使用AppName.Flashcards;
使用AppName.Science;
名称空间AppName
{
公共部分类AppNameHome:ContentPage
{
公立学校
{
初始化组件();
var name=新列表
{
新工具(“互联网”、“web.png”),
新工具(“电子邮件”、“email.png”),
新工具(“Math”、“Math.png”),
新工具(“科学”、“sci.png”),
新工具(“手写”、“Handwrite.png”),
新工具(“FlashCards”、“flashcard.png”),
};
listView.ItemsSource=名称;
}
已选择无效(对象发送方,SelectedItemChangedEventArgs e)
{
var tools=e.选择editem作为工具;
if(tools==null)
{
返回;
}
ContentPage=null;
开关(tools.Name)
{
案例“数学”:
page=新的MathPage();
打破
“互联网”案例:
OpenUri(新的Uri(“http://www.google.com"));
页面=新的AppNameHome();
打破
案例“电子邮件”:
OpenUri(新的Uri(“mailto:”);
页面=新的AppNameHome();
打破
案例“抽认卡”:
页面=新的FlashCardHome();
打破
案例“科学”:
page=新科学主页();
打破
违约:
页面=新的AppNameHome();
打破
}
((列表视图)发件人)。选择EdItem=null;
page.BindingContext=工具;
Navigation.PushAsync(第页);
}
public void OpenBooks(对象发送者、事件参数e)
{
交换机(Device.OS)
{
案例TargetPlatform.iOS:
OpenUri(新的Uri(“itms书籍”);
打破
案例TargetPlatform.Android:
DependencyService.Get().openBooks();
打破
}
}
public void gotosettings(对象发送方、事件参数)
{
Navigation.PushAsync(新设置spage());
}
}
}
任何帮助都将是惊人的

提前谢谢

你试过了吗

获取或设置将在上显示的字符串、绑定或视图 列表视图的底部

所以你会有这样的想法:

<ListView x:Name="listView" HasUnevenRows="true"  ItemSelected="OnItemSelected"> Grid.Row="0" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
<ListView.ItemTemplate>
  <DataTemplate>
    <ViewCell>
      <Frame Padding="0,0,0,8" BackgroundColor="#d2d5d7">
        <Frame.Content>
          <Frame Padding="15,15,15,15"   OutlineColor="Gray" BackgroundColor="White">
            <Frame.Content>
              <StackLayout Padding="20,0,0,0"  Orientation="Horizontal">

                <Image
                        HorizontalOptions="Start"
                        Source="{Binding Image}"/>
                <Label 
                       HorizontalOptions="CenterAndExpand"
                       Text="{Binding Name}"
                       FontFamily="OpenSans-Light"
                       FontSize="24"/>
              </StackLayout>
            </Frame.Content>
          </Frame>
        </Frame.Content>
      </Frame>
    </ViewCell>
  </DataTemplate>
</ListView.ItemTemplate>
<ListView.Footer>
   <Grid BackgroundColor="#eff3f6" Padding="0,0,0,0">
      <Grid.ColumnDefinitions>
         <ColumnDefinition Width="*"/>
         <ColumnDefinition Width="*"/>
          <ColumnDefinition Width="*"/>
      </Grid.ColumnDefinitions>
      <StackLayout Orientation="Horizontal"  VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
           <Button  Grid.Row="0" Grid.Column="1" Image="books.png" HorizontalOptions="CenterAndExpand" BackgroundColor="Transparent" Clicked="OpenBooks" />
           <Button  Grid.Row="0" Grid.Column="2"  HorizontalOptions="EndAndExpand" BorderColor="Transparent" BackgroundColor="Transparent" Clicked="gotosettings" />
       </StackLayout>
    </Grid>
</ListView.Footer>
</ListView>
Grid.Row=“0”VerticalOptions=“FillAndExpand”HorizontalOptions=“FillAndExpand”>

您能给我们看一下您的
App.xaml.cs
中的一些代码吗?我假设您将页面包装在
导航页面中,因此我需要检查您如何初始化页面。因此,请给我看一下你的
应用程序
类的构造函数,在那里你设置了
MainPage=XXX
。Robin Manuel Thiel添加了c代码,请检查帖子中的编辑:)哦,你添加了页面的代码,但我要求了整个应用程序初始化页面的部分。请在项目中找到一个
App.cs
App.xaml.cs
文件,其中会出现“MainPage=XXX”行。这就是我需要看到的。列表视图页脚起了作用,但是stacklayout使我的所有图标都向左移动,一旦我拿出stacklayout,它就像一个符咒!非常感谢你!
<ListView x:Name="listView" HasUnevenRows="true"  ItemSelected="OnItemSelected"> Grid.Row="0" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
<ListView.ItemTemplate>
  <DataTemplate>
    <ViewCell>
      <Frame Padding="0,0,0,8" BackgroundColor="#d2d5d7">
        <Frame.Content>
          <Frame Padding="15,15,15,15"   OutlineColor="Gray" BackgroundColor="White">
            <Frame.Content>
              <StackLayout Padding="20,0,0,0"  Orientation="Horizontal">

                <Image
                        HorizontalOptions="Start"
                        Source="{Binding Image}"/>
                <Label 
                       HorizontalOptions="CenterAndExpand"
                       Text="{Binding Name}"
                       FontFamily="OpenSans-Light"
                       FontSize="24"/>
              </StackLayout>
            </Frame.Content>
          </Frame>
        </Frame.Content>
      </Frame>
    </ViewCell>
  </DataTemplate>
</ListView.ItemTemplate>
<ListView.Footer>
   <Grid BackgroundColor="#eff3f6" Padding="0,0,0,0">
      <Grid.ColumnDefinitions>
         <ColumnDefinition Width="*"/>
         <ColumnDefinition Width="*"/>
          <ColumnDefinition Width="*"/>
      </Grid.ColumnDefinitions>
      <StackLayout Orientation="Horizontal"  VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
           <Button  Grid.Row="0" Grid.Column="1" Image="books.png" HorizontalOptions="CenterAndExpand" BackgroundColor="Transparent" Clicked="OpenBooks" />
           <Button  Grid.Row="0" Grid.Column="2"  HorizontalOptions="EndAndExpand" BorderColor="Transparent" BackgroundColor="Transparent" Clicked="gotosettings" />
       </StackLayout>
    </Grid>
</ListView.Footer>
</ListView>