Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8771139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:42:42+00:00 2026-06-13T17:42:42+00:00

I am using a slightly modified version of this SimpleExpander so that my expander

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T17:42:43+00:00Added an answer on June 13, 2026 at 5:42 pm
    1. Add a new ResourceDictionary to your project (name it RD1.xaml), move your Template into it.

    2. Add a new Class (name it RD1.xaml.cs) with this signature

      public partial class SomeClassName : ResourceDictionary
      
    3. Add this line of code to the ResourceDictionary tag (in RD1.xaml)

      x:Class="WpfApplication1.SomeClassName"
      
    4. Add these lines of code to App.xaml (add FolderName if RD1 is in a folder)

      <Application.Resources>
              <ResourceDictionary>
                  <ResourceDictionary.MergedDictionaries>
                      <ResourceDictionary Source="FolderName\RD1.xaml"/>
                  </ResourceDictionary.MergedDictionaries>
              </ResourceDictionary>
      </Application.Resources>
      
    5. Now you can have your event handler implementation in RD1.xaml.cs

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using a slightly modified version of this code . to create a
I'm using jQuery (1.6.4) and using a slightly modified version of this method to
~ I am using a very slightly modified version of the jQuery tooltip script
I am using a slightly modified version of the Sun's example JTreeTable backed by
I'm using a slightly modified version of Valum's upload [ github link ], I've
I am using a slightly modified version of the DotZlib which is part of
I'm using a slightly modified version of Twain Dot Net in my scanning application.
This is a slightly tricky question. I am using NSDateFormatter on the iPhone but
using this http://bl.ocks.org/950642 we can see how to add images to nodes, the question
I'm going to use the sample code from http://gettinggeneticsdone.blogspot.com/2009/11/split-apply-and-combine-in-r-using-plyr.html for this example. So, first,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.