Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Changing label text in shell flyout header from content page

I am trying to develop a shell with login option and certain menu options after login. The menu options are kept in flyout.

<Shell.FlyoutHeader>



</Shell.FlyoutHeader>

<FlyoutItem Route="Menu" Title="Menu" Shell.TabBarIsVisible="False" FlyoutDisplayOptions="AsMultipleItems">
    <ShellContent Route="Opt1" Title="Option 1" Icon="1.png" IsTabStop="True" ContentTemplate="{DataTemplate local:Opt1}" />
    <ShellContent Route="Opt2" Title="Option2" Icon="2.png" IsTabStop="True" ContentTemplate="{DataTemplate local:Opt2}" />
</FlyoutItem>

I want to pass the login name to flyout header. But since the shell page loads first and then it moves to login page, no value is passed to it. What could be possible solution

Thanks

Answers

  • snehaltechforiasnehaltechforia Member ✭✭

    @snehaltechforia said:
    I am trying to develop a shell with login option and certain menu options after login. The menu options are kept in flyout.

    <Shell.FlyoutHeader>



    </Shell.FlyoutHeader>

    <FlyoutItem Route="Menu" Title="Menu" Shell.TabBarIsVisible="False" FlyoutDisplayOptions="AsMultipleItems">
        <ShellContent Route="Opt1" Title="Option 1" Icon="1.png" IsTabStop="True" ContentTemplate="{DataTemplate local:Opt1}" />
        <ShellContent Route="Opt2" Title="Option2" Icon="2.png" IsTabStop="True" ContentTemplate="{DataTemplate local:Opt2}" />
    </FlyoutItem>
    

    I want to pass the login name to flyout header. But since the shell page loads first and then it moves to login page, no value is passed to it. What could be possible solution

    Thanks

    I am calling the text setting function in OnAppearing only, still no success

  • jezhjezh Member, Xamarin Team Xamurai

    If I understand correctly, I think it makes more sense to log in first and then go to the shell page.

    If you want to change the shell flyout header, you can refer to : https://docs.microsoft.com/en-ie/xamarin/xamarin-forms/app-fundamentals/templates/control-template

                <ControlTemplate x:Key="TealTemplate">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="0.1*" />
                            <RowDefinition Height="0.8*" />
                            <RowDefinition Height="0.1*" />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="0.05*" />
                            <ColumnDefinition Width="0.95*" />
                        </Grid.ColumnDefinitions>
                        <BoxView Grid.ColumnSpan="2" Color="Teal" />
                        <Label Grid.Column="1" Text="{TemplateBinding Parent.HeaderText}" TextColor="White" VerticalOptions="Center" />
                        <ContentPresenter Grid.Row="1" Grid.ColumnSpan="2" />
                        <BoxView Grid.Row="2" Grid.ColumnSpan="2" Color="Teal" />
                        <Label Grid.Row="2" Grid.Column="1" Text="{TemplateBinding Parent.FooterText}" TextColor="White" VerticalOptions="Center" />
                    </Grid>
                </ControlTemplate>
    

    And there is a sample included in above link, you can check it here:
    https://docs.microsoft.com/en-ie/samples/xamarin/xamarin-forms-samples/templates-controltemplatedemos/

  • snehaltechforiasnehaltechforia Member ✭✭

    Thanks for answer.
    But logging in before navigating to shell page would mean moving the login page out of shell.
    How may I navigate to shell page from content page.

    And OnAppearing is working, but when any change is made on the shell page. However in my case since login is also present on the same s

  • jezhjezh Member, Xamarin Team Xamurai

    For creating a login flow with Xamarin Forms Shell, you can refer to the following article: https://mallibone.com/post/xamarin-forms-shell-login

Sign In or Register to comment.