I am using a slightly modified version of this SimpleExpander so that my expander headers are clickable.
http://www.codeproject.com/Articles/248112/Templating-WPF-Expander-Control
Here is the relevant source code:
<ControlTemplate x:Key="SimpleExpanderTemp" TargetType="{x:Type Expander}">
<DockPanel>
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal">
<ToggleButton x:Name="ExpanderButton" />
<!-- button with hard coded click handler -->
<Button Name="SharerHeader" Click="SharerHeader_Click_1">
<ContentPresenter Content="{TemplateBinding Header}" />
</Button>
</StackPanel>
</DockPanel>
</ControlTemplate>
Works great. Now I want to reuse this control template across my application, so I moved the code into my app.xaml. However, my header is hardcoded to a click event, and I want to be able to set the click handler based on the page the expander is being used in. How can I accomplish this?
Add a new ResourceDictionary to your project (name it RD1.xaml), move your Template into it.
Add a new Class (name it RD1.xaml.cs) with this signature
Add this line of code to the ResourceDictionary tag (in RD1.xaml)
Add these lines of code to App.xaml (add FolderName if RD1 is in a folder)
Now you can have your event handler implementation in RD1.xaml.cs