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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T03:10:41+00:00 2026-05-15T03:10:41+00:00

I need to have a command handler for a ToggleButton that can take multiple

  • 0

I need to have a command handler for a ToggleButton that can take multiple parameters, namely the IsChecked property of said ToggleButton, along with a constant value, which could be a string, byte, int… doesn’t matter.

I found this great question on SO and followed the answer’s link and read up on MultiBinding and IMultiValueConverter. It went really smoothly until I had to write the MultiBinding, when I realized that I also need to pass a constant value and couldn’t do something like

<Binding Value="1" />

I then came across another similar question that Kent Boogaart answered, and then I started to think about ways that I could get around this.

One possible way is to not use MVVM and simply add the Tag property to my ToggleButton, in which case my MultiBinding would look like this:

<MultiBinding Converter="{StaticResource MyConverter}">
    <MultiBinding.Bindings>
        <Binding Path="IsChecked" />
        <Binding Path="Tag" />
    </MultiBinding.Bindings>
</MultiBinding>

Kent had made a comment along the lines of, “if you’re using MVVM you should be able to get around this issue”. However, I’m not sure that’s an option for me, even though I have adopted MVVM as my WPF pattern of necessity choice.

The reason why I say this is that I have wayyyy more than one ToggleButton in the UserControl, and each of the ToggleButtons’ Commands need to call the same function. But since they are ToggleButtons, I can’t use the property bound to IsChecked in the ViewModel, because I don’t know which one was last clicked. I suppose I could add another private property to keep track of this, but it seems a little silly. As far as the constant goes, I could probably get rid of this if I did the tracking idea, but not sure of any other way to get around it.

Does anyone have good suggestions for me here? 🙂

EDIT — ok, so I need to update my bindings, which still don’t work quite right:

    <ToggleButton Tag="1" Command="{Binding MyCommand}" Style="{StaticResource PassFailToggleButtonStyle}" HorizontalContentAlignment="Center" Background="Transparent" BorderBrush="Transparent" BorderThickness="0">
        <ToggleButton.CommandParameter>
            <MultiBinding Converter="{StaticResource MyConverter}">
                <MultiBinding.Bindings>
                    <Binding Path="IsChecked" RelativeSource="{RelativeSource Mode=Self}" />
                    <Binding Path="Tag" RelativeSource="{RelativeSource Mode=Self}" />
                </MultiBinding.Bindings>
            </MultiBinding>
        </ToggleButton.CommandParameter>
    </ToggleButton>

IsChecked was working, but not Tag. I just realized that Tag is a string… duh. It’s working now! The key was to use a RelativeSource of Self.

  • 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-15T03:10:42+00:00Added an answer on May 15, 2026 at 3:10 am

    As explained above, I figured it out. I had to use Self for RelativeSource and that did the trick.

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

Sidebar

Ask A Question

Stats

  • Questions 438k
  • Answers 438k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer my %sum; for (@a) { $sum{ $_->{author} }{ $_->{title} }… May 15, 2026 at 4:43 pm
  • Editorial Team
    Editorial Team added an answer I don't know of any class that you can use… May 15, 2026 at 4:43 pm
  • Editorial Team
    Editorial Team added an answer In the layout set your input method options to search.… May 15, 2026 at 4:43 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.