xamarin common template elements

I want to know how do i add re-usable floating menu to all the pages of a xamarin app ?

Do we have a option to create a master page layout and add partial views in xamarin ?

For example in the below Template i want to repeat following stacklayout section in all the pages.

On page i have following

<ContentPage.Content>
            <ScrollView>
                <StackLayout BackgroundColor="MediumPurple" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" >
                    <StackLayout Orientation="Horizontal"  HorizontalOptions="FillAndExpand" BackgroundColor="White">
                        <StackLayout Orientation="Vertical"  HorizontalOptions="FillAndExpand" >
                            <Button Text="All" Clicked="PromoAll_Clicked" BackgroundColor="Orange"  />
                        </StackLayout>
                    </StackLayout>
                    <Label Text="Upcoming Events" VerticalTextAlignment="Center" FontSize="Large" TextColor="White" HorizontalOptions="Center" />
                    <ListView x:Name="PromolistView"   ItemTapped="promoOnItemSelected" RowHeight="55" BackgroundColor="MediumPurple" HasUnevenRows="True" HorizontalOptions="FillAndExpand"  VerticalOptions="FillAndExpand">
                        <ListView.ItemTemplate>
                            <DataTemplate>
                                <ViewCell>
                                    ....
                            </DataTemplate>
                        </ListView.ItemTemplate>
                    </ListView>

                    // this area needs to be repeated every page 
                    <StackLayout Orientation="Horizontal" VerticalOptions="End">
                        <Button Text="A" FontAttributes="Bold"  BackgroundColor="MediumSlateBlue" BorderRadius="50" TextColor="White"></Button>
                        <Button Text="B" FontAttributes="Bold"  BackgroundColor="MediumSlateBlue"  TextColor="White"></Button>
                    </StackLayout>
                    //end of the floating menu 
                </StackLayout>
            </ScrollView>
        </ContentPage.Content>

1 answer

  • answered 2018-07-12 10:14 TeamTam

    In Xamarin.Forms, a Control Template and View is somewhat analogous to a master page layout and partial view in ASP.NET.