Visually Located

XAML and GIS

Customizing the “selected” HubSection Header

I saw a question today about changing the foreground color of the “visible” or “selected” HubSection. Someone had pointed out that I have a behavior for getting the selected index of a Hub and it could be combined with a converter to give the desired output. I thought the solution to this problem was actually quiet simpler. If we can change the visual state of the hub sections when they change, we can give them a “selected” or “unselected” state. For this we can listen to the SectionsIsViewChanged event public class CustomHub : Hub{ HubSection _lastSelectedSection = null;  public CustomHub() { SectionsInViewChanged += OnSectionsInViewChanged; }  private void OnSectionsInViewChanged(object sender, SectionsInViewChangedEventArgs sectionsInViewChangedEventArgs) { if (_lastSelectedSection == SectionsInView[0]) return; VisualStateManager.GoToState(SectionsInView[0], "Selected", true); if (_lastSelectedSection != null) {... [More]