locked
Hub. Focus navigation between HubSection.

    Question

  • Hello. I have hub with two hubSection.

    <Page.Resources>
        <CollectionViewSource x:Name="firstCollection"/>
        <CollectionViewSource x:Name="secondCollection"/>
    </Page.Resources>
    
    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <Hub>
            <HubSection>
                <DataTemplate>
                    <GridView ItemsSource="{Binding Source={StaticResource firstCollection}}" SelectionMode="None">
    
                    </GridView>
                </DataTemplate>
            </HubSection>
            <HubSection>
                <DataTemplate>
                    <GridView ItemsSource="{Binding Source={StaticResource secondCollection}}" SelectionMode="None"/>
                </DataTemplate>
            </HubSection>
        </Hub>
    </Grid>
    public MainPage()
        {
            this.InitializeComponent();
    
            List<Border> firstList = new List<Border>();
            //Generate items...
            firstCollection.Source = firstList;
    
            List<Border> secondList = new List<Border>();
            //Generate items...
            secondCollection.Source = secondList;
    
        }
    }

    I need to make select(focus) navigation between sections, using the arrow keys (like in Microsoft Jigsaw in main page. http://apps.microsoft.com/windows/en-us/app/microsoft-jigsaw/cb510dbd-d970-43ac-941a-ac0a9d7506b2). How i can do this? Now, focus only works in the first section. Thank you.




    • Edited by erofeevn Saturday, August 30, 2014 9:15 AM
    Saturday, August 30, 2014 8:45 AM

Answers

  • Hi erofeevn,

    I did not download the app from store, but I can probably understand what you mean by your word: I need to make select(focus) navigation between sections, using the arrow keys. 

    To listen to a keyboard action is necessary: Keyboard interactions, once a keydown event triggered, we may need to check if the key equals to "Left" or "Right" arrow, then we can determine the current hubsection by SectionsInView, ScrollToSection is what we need here to navigate between sections for your scenario.

    But I don't understand what do you mean by focus only work in the first section, could you explain more for this? You may need to go through the documentation: Events and routed events overview, you should be able to know how to pass the keydown event to a hub control.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Monday, September 1, 2014 5:21 AM
    Moderator