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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:16:30+00:00 2026-06-04T17:16:30+00:00

I have the following sample which mimics an application with a menu and a

  • 0

I have the following sample which mimics an application with a menu and a status bar button doing the same thing.

If I only execute the command from the menu the toolbar button gets updated fine but if I start using the toolbarbutton the menu and the toolbar gets out of synch. The same happens if I do the other way around starting with the toolbar button the menu gets updated until I use the menu for the fist time.

What I’m missing?

C#:

using System.ComponentModel;
using System.Windows.Input;
using Picis.Wpf.Framework.Commands;

namespace CheckTest
{
public partial class Window1 : INotifyPropertyChanged
{
    private bool _state;

    public ICommand ChangeStateCommand { get; private set; }

    public bool State
    {
        get
        {
            return _state;
        }
        set
        {
            if (_state != value)
            {
                _state = value;
                this.OnPropertyChanged("State");
            }
        }
    }

    public Window1()
    {
        this.ChangeStateCommand = new DelegateCommand<bool>(ExecuteChangeState);
        InitializeComponent();
        this.DataContext = this;
    }

    #region INotifyPropertyChanged Members

    public event PropertyChangedEventHandler PropertyChanged;

    protected virtual void OnPropertyChanged(string name)
    {
        if (this.PropertyChanged != null)
        {
            this.PropertyChanged(this, new PropertyChangedEventArgs(name));
        }
    }

    #endregion

    private void ExecuteChangeState(bool state)
    {
        this.State = !state;
    }
}
}

XAML:

<Window x:Class="CheckTest.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<StackPanel>
    <Menu IsMainMenu="True">
        <MenuItem IsChecked="{Binding State, Mode=OneWay}" Command="{Binding ChangeStateCommand}" CommandParameter="{Binding State}" Header="Test" IsCheckable="True"  />
    </Menu>
    <ToggleButton IsChecked="{Binding State, Mode=OneWay}" Command="{Binding ChangeStateCommand}" CommandParameter="{Binding State}" Content="Test2" />
</StackPanel>
</Window>
  • 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-04T17:16:31+00:00Added an answer on June 4, 2026 at 5:16 pm

    I have imported your code into a new project.
    I had to import my implementation of Delegate command which is basically the non generic version of relay command by Josh Smith and everything works fine (the two items remain synced no matter which order they are clicked).

    The only update to the code I made was the following which basically accommodates the fact that my version of delegate command is non-generic.

    private void ExecuteChangeState(object parameter)
    {
        bool s = (bool)parameter;
        this.State = !s;
    }
    

    The xaml remains unchanged from your post (My understanding is that the Path parameter is implicit in the binding so it makes no difference if it is specified or not).

    I’m suspecting the issue could be that there is something wrong with the implementation of DelegateCommand you are working with. Alternatively, the sample you posted might be missing something from your actual application that is giving you the problem.

    Are you certain the code you have posted adequately models the problem you are experiencing?

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

Sidebar

Related Questions

I am trying a sample application in which I have taken following controls: i.
I have the following sample code which doesn't seem to want to run. import
I have the following sample dataset (below and/or as CSVs here: http://goo.gl/wK57T ) which
I have the following sample code, which I expect to color the panel on
I have the following sample code. class bar is derived from the base class
I have the following XML sample which I need to parse in order to
I have the following code sample, which produces an error with the included constant
I have the following sample code which gets a list of values from a
I have created sample application which can call show all contacts (phone numbers). But
I have the following page (deadlink: http://www.workingstorage.com/Sample.htm ) that has a footer which I

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.