xaml टैब्ड पेज अंदर मास्टर विस्तार पेज Xamarin




navigation prism (2)

आप XAML में इस तरह के TabbedPage बच्चों को जोड़ सकते हैं:

<MasterDetailPage.Detail>
    <TabbedPage>
        <TabbedPage.Children>
            <ContentPage Title="Page 1" Icon="ja.png" />
            <ContentPage Title="Page 2" Icon="ja.png" />
            <ContentPage Title="Page 3" Icon="ja.png" />
        </TabbedPage.Children>
    </TabbedPage>
</MasterDetailPage.Detail>

सामग्री पृष्ठ के लिए अपने "स्थानीय" कस्टम पृष्ठों का स्थान ContentPage

या कोड के माध्यम से:

public TabsPage ()
{
    this.Children.Add (new ContentPage () { Title = "Page 1", Icon = "ja.png" });
    this.Children.Add (new ContentPage () { Title = "Page 2", Icon = "ja.png" });
    this.Children.Add (new ContentPage () { Title = "Page 3", Icon = "ja.png" });
}

अद्यतन करें:

सुशी हॉंगओवर द्वारा सुझाए गए अनुसार मैंने कुछ बदलाव किए, अब मैं कोई त्रुटि नहीं प्राप्त करता हूं लेकिन मेरी टैबेड मेनू दिखाई नहीं दे रहा है

मैं xamarin दस्तावेज़ीकरण में दिखाए गए अनुसार एक टैबयुक्त पृष्ठ जोड़ने का प्रयास कर रहा हूं, लेकिन मैं निम्न त्रुटि को जारी रखता हूं, System.NullReferenceException "ऑब्जेक्ट संदर्भ किसी ऑब्जेक्ट के किसी उदाहरण में सेट नहीं है।" क्या मुझे प्रत्येक पृष्ठ के लिए एक नया ऑब्जेक्ट घोषित करने की आवश्यकता है या क्या यह xaml का प्रयोग करते समय स्वचालित रूप से किया जाता है?

यहां मेरा स्टैकट्रेस है,

  at Xamarin.Forms.Platform.Android.AppCompat.Platform.LayoutRootPage(Xamarin.Forms.P age page, Int32 width, Int32 height) [0x0005d] in   C:\BuildAgent\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\AppCompat\Plat form.cs:279 
  at Xamarin.Forms.Platform.Android.AppCompat.Platform.Xamarin.Forms.Platform.Android.IPlatformLayout.OnLayout (Boolean changed, Int32 l, Int32 t, Int32 r, Int32 b) [0x00003] in C:\BuildAgent\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\AppCompat\Platform.cs:196 
  at Xamarin.Forms.Platform.Android.PlatformRenderer.OnLayout (Boolean changed, Int32 l, Int32 t, Int32 r, Int32 b) [0x0000e] in C:\BuildAgent\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\PlatformRenderer.cs:73 
  at Android.Views.ViewGroup.n_OnLayout_ZIIII (IntPtr jnienv, IntPtr native__this, Boolean changed, Int32 l, Int32 t, Int32 r, Int32 b) [0x00009] in /Users/builder/data/lanes/3415/7db2aac3/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.Views.ViewGroup.cs:3427 
  at (wrapper dynamic-method) System.Object:d59f31f1-b9b6-40ea-9254-a422fe409750 (intptr,intptr,bool,int,int,int,int)

यहाँ मेरा कोड है,

using Xamarin.Forms;
namespace BSi.Mobile.Events.Views
{
    public partial class MainMasterDetailPage : MasterDetailPage
    {
        public MainMasterDetailPage()
        {
            InitializeComponent();
        }
    }
}

<?xml version="1.0" encoding="utf-8" ?>
<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
              xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
              xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
              xmlns:local="clr-namespace:BSi.Mobile.Events.Views;assembly=BSi.Mobile.Events"
              prism:ViewModelLocator.AutowireViewModel="True"
              x:Class="BSi.Mobile.Events.Views.MainMasterDetailPage">
    <MasterDetailPage.Master>
       <ContentPage Title="Default" Padding="10">
          <StackLayout>
             <Button Text="Home" Command="{Binding MenuSelectedCommand}"  CommandParameter="NavigationPage\MainPage"/>
             <Button Text="Event Schedule" Command="{Binding MenuSelectedCommand}" CommandParameter="NavigationPage\EventPage"/>
             <Button Text="Floor Plan" Command="{Binding MenuSelectedCommand}" CommandParameter="NavigationPage\FloorPlanPage"/>
             <Button Text="Sponsor/Media Partners" Command="{Binding MenuSelectedCommand}" CommandParameter="NavigationPage\SponsorsPage"/>
             <Button Text="Where To Eat" Command="{Binding MenuSelectedCommand}" CommandParameter="NavigationPage\FoodNearbyPage"/>
          </StackLayout>
       </ContentPage>
   </MasterDetailPage.Master>
   <MasterDetailPage.Detail>
       <TabbedPage>
           <TabbedPage.Children>
              <local:MainPage Title="Info" Icon="http://icons.iconarchive.com/icons/graphicloads/100-flat/256/home-icon.png"/>
              <local:EventPage Title="Sessions" Icon="http://icons.iconarchive.com/icons/graphicloads/100-flat/256/home-icon.png"/>
              <local:SpeakersPage Title="Speakers" Icon="http://icons.iconarchive.com/icons/graphicloads/100-flat/256/home-icon.png"/>
              <local:ExhibitsPage Title="Exhibits" Icon="http://icons.iconarchive.com/icons/graphicloads/100-flat/256/home-icon.png"/>
           </TabbedPage.Children>
       </TabbedPage>
   </MasterDetailPage.Detail>
</MasterDetailPage>

इसका जवाब कमांड पैरामीटर का उपयोग करना था जो कि टैबबेड पृष्ठ में प्रदर्शित होने वाले पृष्ठों के सापेक्ष है।

<?xml version="1.0" encoding="utf-8"?>
<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
              xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
              xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
              prism:ViewModelLocator.AutowireViewModel="True"
              x:Class="BSi.Mobile.Events.Views.MainMasterDetailPage">
<MasterDetailPage.Master>
   <ContentPage Title="Default">
     <StackLayout>
       <StackLayout BackgroundColor="{StaticResource iconGray}" Padding="15"      HeightRequest="100">
         <Image Source="canfitpro_logo2" HeightRequest="60" HorizontalOptions="Start" VerticalOptions="EndAndExpand" />
       </StackLayout>
       <TableView Intent="Form" HasUnevenRows="True">
         <TableRoot>
           <TableSection Title="Vancouver Fitness Expo">
             <ViewCell>
              <StackLayout Margin="15, 10, 10, 10" Orientation="Horizontal">
                 <StackLayout.GestureRecognizers>
                   <TapGestureRecognizer Command="{Binding MenuSelectedCommand}" CommandParameter="EventTabbedPage/NavigationPage/MainPage"/>
                 </StackLayout.GestureRecognizers>
                 <Image Source="icon_home_circle" HeightRequest="40"/>
                 <Label Text="Home" VerticalTextAlignment="Center" Margin="20, 0, 0, 0" Style="{DynamicResource SubtitleStyle}"/>
               </StackLayout>
             </ViewCell>
             <ViewCell>
               <StackLayout Margin="15, 10, 10, 10" Orientation="Horizontal">
                 <StackLayout.GestureRecognizers>
                   <TapGestureRecognizer Command="{Binding MenuSelectedCommand}" CommandParameter="EventTabbedPage/NavigationEventPage"/>
                 </StackLayout.GestureRecognizers>
                 <Image Source="icon_sessions_circle" HeightRequest="40"/>
                 <Label Text="Sessions" VerticalTextAlignment="Center" Margin="20, 0, 0, 0" Style="{DynamicResource SubtitleStyle}"/>
               </StackLayout>
             </ViewCell>
           </TableSection>
           <TableSection Title="Resources">
             <ViewCell>
               <StackLayout Margin="15, 10, 10, 10" Orientation="Horizontal">
                 <StackLayout.GestureRecognizers>
                   <TapGestureRecognizer Command="{Binding MenuSelectedCommand}" CommandParameter="NavigationPage/FloorPlanPage"/>
                 </StackLayout.GestureRecognizers>
                 <Image Source="icon_floormap_circle" HeightRequest="40"/>
                 <Label Text="Floor Plan" VerticalTextAlignment="Center" Margin="20, 0, 0, 0" Style="{DynamicResource SubtitleStyle}"/>
               </StackLayout>
             </ViewCell>
             <ViewCell>
               <StackLayout Margin="15, 10, 10, 10" Orientation="Horizontal">
                 <StackLayout.GestureRecognizers>
                   <TapGestureRecognizer Command="{Binding MenuSelectedCommand}" CommandParameter="NavigationPage/SponsorsPage"/>
                 </StackLayout.GestureRecognizers>
                 <Image Source="icon_partners_circle" HeightRequest="40"/>
                 <Label Text="Sponsor / Media Partners" VerticalTextAlignment="Center" Margin="20, 0, 0, 0" Style="{DynamicResource SubtitleStyle}"/>
               </StackLayout>
             </ViewCell>
             <ViewCell>
               <StackLayout Margin="15, 10, 10, 10" Orientation="Horizontal">
                 <StackLayout.GestureRecognizers>
                   <TapGestureRecognizer Command="{Binding MenuSelectedCommand}" CommandParameter="NavigationPage/FoodNearbyPage"/>
                 </StackLayout.GestureRecognizers>
                 <Image Source="icon_restaurant_circle" HeightRequest="40"/>
                 <Label Text="Where To Eat" VerticalTextAlignment="Center" Margin="20, 0, 0, 0" Style="{DynamicResource SubtitleStyle}"/>
               </StackLayout>
             </ViewCell>
           </TableSection>
         </TableRoot>        
       </TableView>        
     </StackLayout>
   </ContentPage>
  </MasterDetailPage.Master>
</MasterDetailPage>




tabbed