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 795831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T22:32:33+00:00 2026-05-14T22:32:33+00:00

I would like to create a set of custom controls that are basically image

  • 0

I would like to create a set of custom controls that are basically image buttons (it’s a little more complex than that, but that’s the underlying effect I’m going for) that I’ve seen a few different examples for. However, I would like to further extend that to also allow radio/toggle buttons.

What I’d like to do is have a common abstract class called ImageButtonBase that has default implementations for ImageSource and Text, etc. That makes a regular ImageButton implementation pretty easy.

The issue I am having is creating the RadioButton flavor of it. As I see it, there are at least three options:

  1. It would be easy to create something that derives from RadioButton, but then I can’t use the abstract class I’ve created.
  2. I could change the abstract class to an interface, but then I lose the abstract
    implementations, and will in fact have duplication of code.
  3. I could derive from my abstract class, and re-implement the RadioButton-type
    properties and events (IsChecked, GroupName, etc.), but that certainly doesn’t seem like a great idea.

Note: I have seen How to get a group of toggle buttons to act like radio buttons in WPF?, but what I want to do is a little more complex.

I’m just wondering if anybody has an example of an implementation, or something that might be adapted to this kind of scenario. I can see pros and cons of each of the ideas above, but each comes with potential pitfalls.

Thanks,
wTs

  • 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-14T22:32:33+00:00Added an answer on May 14, 2026 at 10:32 pm

    I think your best solution here is to use attached properties instead of subclassing. This will allow you to have your cake and eat it too.

    Instead of writing this:

    <my:CustomButton ImageSource="Abc" Text="Def" ... />
    

    you would write this:

    <Button my:ButtonLook.ImageSource="Abc" my:ButtonLook.Text="Def" ... />
    

    This will work with data binding and everything. To implement this, create your “ButtonLook” class deriving from DependencyObject, and create the two attached properties using the “propa” snippet in Visual Studio. Then set a PropertyChangedCallback on each to construct update the ContentControl.Content property on whatever they are attached to.

    An alternative solution is to embed a hidden RadioButton inside your CustomRadioButton subclass, give it an empty template to make it invisible, and bind the IsChecked and GroupName properties:

    <ControlTemplate TargetType="my:CustomRadioButton">
      <Grid>
        <RadioButton IsChecked="{Binding ToggleButton.IsChecked, RelativeSource={RelativeSource TemplatedParent}}"
                     GroupName="{TemplateBinding GroupName}">
          <RadioButton.Template><ControlTemplate /></RadioButton.Template>
        </RadioButton>
        ... visual part here ...
    

    Be sure that your CustomToggleButton and CustomRadioButton subclasses use AddOwner to create DependencyProperties such as IsChecked and GroupName rather than creating new ones.

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

Sidebar

Related Questions

I would like create my own collection that has all the attributes of python
I would like create a web service in ASP.Net 2.0 that will supports JSON.
I would like to create a stored procedure in MySQL that took a list
I would like to create events for certain resources that are used across various
Would like to create a strong password in C++. Any suggestions? I assume it
I would like to create a database backed interactive AJAX webapp which has a
I would like to create an SSL connection for generic TCP communication. I think
I would like to create a file format for my app like Quake, OO,
I would like to create an application wide keyboard shortcut for a Java Swing
I would like to create an XML-based website. I want to use XML files

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.