How can I tell which HubSection is selected

后端 未结 1 1305
天涯浪人
天涯浪人 2021-01-06 04:03

I need to change the contents of an AppBar when a user changes the view in a Hub control.

The way I did it while using a Pivot control is listening to the SelectionC

1条回答
  •  梦毁少年i
    2021-01-06 04:37

    In Hub control, We can listen to the SectionsInViewChanged event. We can get the HubSection which is displayed in screen by this:

    var section = hubDemo.SectionsInView[0];
    

    hubDemo is the name of my Hub control. And we can set Tag property for each HubSection. For example:

    
        
        
        
        
        
    
    

    So we can change AppBar content by tag:

    private void demoHub_SectionsInViewChanged(object sender, SectionsInViewChangedEventArgs e)
    {
        var section = hubDemo.SectionsInView[0];
        var tag = section.Tag.ToString();
        switch (tag)
        {
            // Change your AppBar by tag
        }
    }
    

    0 讨论(0)
提交回复
热议问题