Silverlight HyperlinkButton Background Colour

Oh dear – I think I over thought this one. To cut a long story short, a client app I was maintaining had a top level menu composed of HyperlinkButtons. The requested change would involve a proliferation of these controls.

Solution was to move the controls into sets in separate TabItems in a tab control.

Problem was that the control for the current HyperlinkButton was no longer highlighted. I spent a long time looking at the custom style they had trying to get the required effect back.

Two coffees later it occurred to me to have a look and see if there was any forbidden magic in the code behind. (The rest of the app was strongly MVVM). and yes there it was – the OnNavigated handler iterated through the hyperlink buttons in the original container and used the VisualStateManager to set their state to ActiveLink if the url matched and InactiveLink if not. Doh!

 

This entry was posted in C# and tagged , , . Bookmark the permalink.

Leave a Reply