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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:51:35+00:00 2026-06-13T01:51:35+00:00

Hey I just started working on Toggle Buttons and I have set the properties

  • 0

Hey I just started working on Toggle Buttons and I have set the properties of the button. I want to check for the toggle state which should return me 1 or 0.

XAML:

<ToggleButton Grid.Column="3" Content="On" Command="{Binding VoltageToggleCommand}" IsChecked="{Binding Path=IsChecked}" Name="VoltageToggleBtn" />

ViewModel Class:

private ICommand mToggleButtonCommand;
    public ICommand VoltageToggleCommand
    {
        get
        {
            if (mToggleButtonCommand == null)
                mToggleButtonCommand = new DelegateCommand(new Action(ToggleButtonCommandExecuted), new Func<bool>(ToggleButtonCommandCanExecute));

            return mToggleButtonCommand;
        }
        set
        {
            mToggleButtonCommand = value;
        }
    }

    /// <summary>
    /// Check for ToggleButton State
    /// </summary>
    private bool isChecked;
    public bool IsChecked
    {
        get { return this.isChecked; }
        set
        {
            this.isChecked = value;
            this.OnPropertyChanged("IsChecked");
        }
    }

    public bool ToggleButtonCommandCanExecute()
    {
        return true;
    }

    public void ToggleButtonCommandExecuted()
    {
        Byte[] cmdArray = new Byte[256];
        int numBytes = 0;
        cmdArray[numBytes++] = // Here I wanna retrieve the toggle state i.e. 1 or 0
        // Some Code
    }

Thus when I click the toggle button, controls reaches ToggleButtonCommandExecuted() where I need to check for the state and store it in cmdArray. Basically when code is executed cmdArray[numBytes++] = 1 or 0.

How can I achieve it? 🙂

  • 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-13T01:51:36+00:00Added an answer on June 13, 2026 at 1:51 am

    you will have to convert from boolean to byte yourself

    cmdArray[numBytes++] = (byte)(IsChecked ? 1 : 0);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey everyone, just a quick thing, I have the hex to integer working, but
Hey there I have just started Java for a course I will be taking
Hey guys. I have a model, Item , which is set to expire in
Just started using fadein/fadeout - it's functioning but with problems. I have a set
Hey guys, I just started learning C++ and I have this code that I
hey i just want to gather the locations in google maps database which are
Hey I just started dabbling with android programming, and from my short period of
Hey just a quick question for any experts out there. I have a site
Hey I just wanted to find out the working of the following script as
hey guys I just started trying to convert my query structure to PDO and

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.