Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Shell - Navigate into inner tab of a different Shell

$
0
0

Hello,
I have a main shell page 'AppShell.xaml' with Flyout navigation
In this shell I have 2 FlyoutItem with a single ShellContent (we call it Page1 and Page2) and 1 FlyoutItem with 4 ShellContent (4 tab pages)

From Page1 I need to go into a sandwitch page (with upper and bottom tabs)
For this way I write a second shell page (CoreShell.xaml) with Flyout disabled.

CoreShell.xml:
`<?xml version="1.0" encoding="UTF-8"?>

<Shell.Resources>
    <ResourceDictionary>

    <Style x:Key="BaseStyle" TargetType="Element">  
        <Setter Property="Shell.ShellTabBarBackgroundColor" Value="{StaticResource tabBarBackgroundColor}" />  
     </Style>

    <Style x:Key="SicurezzaStyle" TargetType="Element" BasedOn="{StaticResource BaseStyle}">            
        <Setter Property="Shell.ShellTitleColor" Value="{StaticResource tabSecurityFontColor}" />    
        <Setter Property="Shell.ShellTabBarTitleColor" Value="{StaticResource tabSecurityFontColor}" /> 
        <Setter Property="Shell.ShellForegroundColor" Value="{StaticResource tabSecurityFontColor}" />
    </Style>

    <Style x:Key="SmartHomeStyle" TargetType="Element" BasedOn="{StaticResource BaseStyle}">
        <Setter Property="Shell.ShellTitleColor" Value="{StaticResource tabSmartHomeFontColor}" />
        <Setter Property="Shell.ShellForegroundColor" Value="{StaticResource tabSmartHomeFontColor}" />
    </Style>

    <Style x:Key="ClimaStyle" TargetType="Element" BasedOn="{StaticResource BaseStyle}">
        <Setter Property="Shell.ShellTitleColor" Value="{StaticResource tabClimaFontColor}" />
        <Setter Property="Shell.ShellForegroundColor" Value="{StaticResource tabClimaFontColor}" />
    </Style>

    <Style x:Key="SistemaStyle" TargetType="Element" BasedOn="{StaticResource BaseStyle}">
        <Setter Property="Shell.ShellTitleColor"  Value="{StaticResource tabSistemaFontColor}" />
        <Setter Property="Shell.ShellForegroundColor" Value="{StaticResource tabSistemaFontColor}" />
    </Style>                  
    </ResourceDictionary>

</Shell.Resources>

<ShellItem>
    <Tab Icon="tab_security_unsel"  Title="Sicurezza" Style="{StaticResource SicurezzaStyle}" >    
        <ShellContent Title="Scenari"        ContentTemplate="{DataTemplate view:ScenariPage}" />
        <ShellContent Title="Aree e zone"   ContentTemplate="{DataTemplate view:AreeZonePage}" />
        <ShellContent Title="Telecamere"    ContentTemplate="{DataTemplate view:TelecamerePage}" />
    </Tab>

    <ShellContent Icon="tab_smart_home_unsel" Title="Smart Home" Style="{StaticResource SmartHomeStyle}" 
                  ContentTemplate="{DataTemplate view:SmartHomePage}" />

    <ShellSection Icon="tab_clima_unsel" Title="Clima" Style="{StaticResource ClimaStyle}">
        <ShellContent Title="Clima 1" ContentTemplate="{DataTemplate view:WaitingClimaPage}" />
    </ShellSection>

    <ShellSection Icon="tab_system_unsel" Title="Sistema" Style="{StaticResource SistemaStyle}">
        <ShellContent Title="Generali"  ContentTemplate="{DataTemplate view:GeneraliPage}" />
        <ShellContent Title="Guasti"  ContentTemplate="{DataTemplate view:GuastiPage}" />
        <ShellContent Title="Eventi"  ContentTemplate="{DataTemplate view:EventiPage}" />
    </ShellSection>        

</ShellItem>

`

To show the sandwitch page, I push this Shell page to Navigation;
CoreShell coreShell = new CoreShell();
await Shell.Current.Navigation.PushAsync(coreShell);

and all is working as expected. Of course in this way I see the first upper tab of the first bottom tab

My questions:
1) There is a way to open the coreShell page to a different inner tab?
2) There is a way to add ShellContent to a ShellSection programmatically from behind code? For example, for 'Clima' ShellSection the number of tab is not fixed, and I could build it runtime

Thanks
Matteo


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>