2017-01-09 1 views
0

Привет Я работаю над приложением в Xamarin формах и мой домашний экран пользовательского интерфейса выглядит следующим образом:Как получить сетки навигационной панели, чтобы перейти прямо под видом списка в Xamarin формирует приложение

enter image description here

как Я заставляю навигационную панель идти прямо под карточкой карточек?

вот мой 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> 

EDIT здесь мой C# код:

using System; 
using System.Collections.Generic; 
using AppName.Math; 
using Xamarin.Forms; 
using Plugin.Messaging; 
using AppName.Flashcards; 
using AppName.Science; 

namespace AppName 
{ 
    public partial class AppNameHome : ContentPage 
    { 
     public SchoolToolsHome() 
     { 
      InitializeComponent(); 


      var name = new List<Tools> 
      { 
        new Tools("Internet", "web.png"), 
        new Tools("E-Mail", "email.png"), 
        new Tools("Math", "math.png"), 
        new Tools("Science", "sci.png"), 
        new Tools("Handwriting","handwriteing.png"), 
        new Tools("FlashCards", "flashcard.png"), 
     }; 

      listView.ItemsSource = name; 







     } 

     void OnItemSelected(object sender, SelectedItemChangedEventArgs e) 
     { 

      var tools = e.SelectedItem as Tools; 

      if (tools == null) 
      { 
       return; 
      } 

      ContentPage page = null; 

      switch (tools.Name) 
      { 
       case "Math": 
        page = new MathPage(); 
        break; 
       case "Internet": 
        Device.OpenUri(new Uri("http://www.google.com")); 
        page = new AppNameHome(); 
        break; 

       case "E-Mail": 
        Device.OpenUri(new Uri("mailto:")); 
        page = new AppNameHome(); 

        break; 

       case "FlashCards": 
        page = new FlashCardHome(); 

        break; 


       case "Science": 
        page = new ScienceHome(); 

        break; 



       default: 
        page = new AppNameHome(); 
        break; 

      } 

      ((ListView)sender).SelectedItem = null; 
      page.BindingContext = tools; 
      Navigation.PushAsync(page); 
     } 


       public void OpenBooks(object sender, EventArgs e) 
     { 

      switch (Device.OS) 
      { 
       case TargetPlatform.iOS: 
        Device.OpenUri(new Uri("itms-books:")); 

        break; 


       case TargetPlatform.Android: 
        DependencyService.Get<OpenBookInterface>().openBooks(); 
        break; 
      } 

     } 


       public void gotosettings(object sender, EventArgs e) 
     { 

        Navigation.PushAsync(new SettingsPage()); 

     } 

    } 
} 

любая помощь будет удивительно!

Заранее благодарен!

+0

Можете ли вы показать нам код от вашего 'App.xaml.cs'? Я предполагаю, что вы завершаете свою страницу в «NavigationPage», поэтому мне нужно проверить, как вы инициализируете страницу. Поэтому, пожалуйста, покажите мне конструктор вашего класса «App», где вы задаете «MainPage = XXX». –

+0

Robin-Manuel Thiel добавил код C#, пожалуйста, проверьте изменения в сообщении :) – Phoneswapshop

+0

О, вы добавили код страницы, но я попросил ту часть, где все приложение инициализирует страницу. Пожалуйста, найдите файл 'App.cs' или' App.xaml.cs' в вашем проекте, где появится строка 'MainPage = XXX''. Это то, что мне нужно увидеть. –

ответ

0

Вы попробовали ListView.Footer?

Получает или задает строку, привязку или представление, которое будет отображаться на в нижней части списка.

Таким образом, вы бы что-то вроде:

<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> 
+0

Верхний нижний колонтитул сделал трюк, но stacklayout заставил все мои значки перейти налево, как только я вытащил stacklayout, это сработало как шарм! Спасибо огромное! – Phoneswapshop

Смежные вопросы