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

  • Home
  • SEARCH
  • 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 3454146
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:27:30+00:00 2026-05-18T09:27:30+00:00

I am relatively new to the WPF scene, and am having a problem understanding

  • 0

I am relatively new to the WPF scene, and am having a problem understanding how styles are reused amongst controls.

My example situation is this, I’m making a control that needs a Toggle button. I want this ToggleButton to look like the ‘expand’ Button on a TreeViewItem. How would apply the TreeViewItem’s button style to my own button?

From my searching I have a feeling that it isn’t possible without copying XAML, but I can’t justify to myself why anyone would make a UI framework that limited.

Thanks in advance.

  • 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-05-18T09:27:31+00:00Added an answer on May 18, 2026 at 9:27 am

    I’m not sure there’s a way of retrieving the default style/template from something and applying it to another control in XAML, although you may be able to to it in code. Although that would pose the problem that you just want to get the button part of the template and it’s easier (not to mention cleaner) just to write a new style rather than hacking around to get just that part of the template.

    The problem with restyling buttons is that when pressed they will go back to their default pressed appearance, same for when they are hovered. What you want to do is change the ControlTemplate of the button.

    When I was starting out in WPF I found this tutorial
    to be quite a useful introduction to the process.

    I’d recommend getting a copy of ShowMeTheTemplate to give you access to most of the default templates for controls as that will save a lot of the basic work and give you an insight into how the controls work.

    When you’ve created your control template (or any style/template for that matter), you can store it in a resource dictionary and apply it to controls by referencing it from the relevant property using the StaticResource markup extension.

    Example:

    (In a resource dictionary, for example App.Resources):

    <Style x:Key="myStyle" TargetType="Button">
        <Setter Property="Width" Value="70" />
    </Style>
    

    Used in a button:

    <Button Style="{StaticResource myStyle}" />
    

    Hope this helps get you started.

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

Sidebar

Related Questions

I'm relatively new to WPF. I'm examining some code that looks like this: private
Being relatively new to functional programming, I expend lots of energy wondering is this
I'm relatively new to web application programming so I hope this question isn't too
I'm relatively new to Python and am having problems programming with Scapy, the Python
I am relatively new to WPF, and some things with it are quite foreign
I am relatively new to both WPF and NHibernate and attempting to build an
I'm relatively new to .Net 4 and I am creating my FIRST WPF application
So I'm pretty new to WPF and I'm having trouble with the layout of
I'm still relatively new to Python, so if this is an obvious question, I
I'm relatively new to the WPF world and I'm working on an application where

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.