views:

147

answers:

1

I have a custom UserControl that I created as a navigation menu that parses an xml file and populates itself with hyperlink buttons. So basically my control is an empty stackpanel, and when it's loaded it adds hyperlinkbuttons as children to the stack panel.

In my application I just add a <myLibrary:NavigationMenu links="somexml.xml" />

The problem is that I want to be able to style the hyperlinkbuttons and the stack panel differently for every application. What is the best way to do this.

+1  A: 

In the code behind for the control, create a DependencyProperty of type Style for both HyperlinkStyle and StackPanelStyle. Then when you create the items apply the correct styles too them.

Take a look at MSDN

The article is a good starting point for writing stylable controls.

Stephan