2017-01-09 1 views
0

Hallo ich auf eine App in Xamarin Formen und mein Home-Bildschirm UI wie folgt aussieht arbeite:Wie Gitter Navigationsleiste bekommen direkt unter einer Listenansicht in Xamarin gehen bildet App

enter image description here

wie zu tun Ich bekomme die Navigationsleiste direkt unter der Karteikarte?

hier ist mein XAML-Code:

<?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 mein C# -Code hier:

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()); 

     } 

    } 
} 

jede Hilfe würde erstaunlich sein!

Vielen Dank im Voraus!

+0

Können Sie mir bitte zeigen Sie uns einen Code aus Ihrer 'App.xaml.cs'? Ich gehe davon aus, dass Sie Ihre Seite in eine 'NavigationPage' einbinden, also muss ich prüfen, wie Sie die Seite initialisieren. Also zeig mir bitte den Konstruktor deiner 'App' Klasse, wo du' MainPage = XXX' gesetzt hast. –

+0

Robin-Manuel Thiel hat den C# -Code hinzugefügt, bitte überprüfe die Änderung im Beitrag :) – Phoneswapshop

+0

Oh, du hast den Code der Seite hinzugefügt, aber ich habe nach dem Teil gefragt, wo die ganze App die Seite initialisiert. Bitte suchen Sie eine 'App.cs' oder' App.xaml.cs' Datei in Ihrem Projekt, wo die Zeile 'MainPage = XXX'' erscheint. Das ist, was ich sehen muss. –

Antwort

0

Haben Sie versucht ListView.Footer?

Ruft die Zeichenfolge, die Bindung oder die Ansicht ab, die unter am Ende der Listenansicht angezeigt werden, oder legt diese fest.

Also würde man so etwas wie haben:

<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

Listenansicht Fußzeile hat den Trick gemacht, aber das Stacklayout machte alle meine Icons nach links, sobald ich das Stacklayout herausnahm, funktionierte es wie ein Zauber! Ich danke dir sehr! – Phoneswapshop

Verwandte Themen