Tags: binding, code, framework, lttogglebutton, microsoft, msdn, net, rc1, similar, software, studio, togglebuttonischecked, toltcvoice, visual, xkeyquotmyvoicequot

ToggleButton.IsChecked Binding issue!

On Microsoft » Microsoft Visual Studio

6,706 words with 4 Comments; publish: Wed, 26 Dec 2007 00:24:00 GMT; (300125.00, « »)

I'm using the .NET Framework 3.0 RC1, and in my code I have something similar to:


x:Key="myVoice" />


<ToggleButton Content="Ready" Click="ToggleReadyState"


Source={StaticResource myVoice}, Mode=OneWay,

Path=IsItPossibleToNotReady}" />

I want to bind from the read only "myVoice.IsItPossibleToNotReady" property to the "ToggleButton.IsChecked" property.

So, I use the OneWay mode.

The binding works well until I push the toggle button!!!

Here is a snippet you can use in the XamlPad to illustrate the issue:


<ToggleButton x:Name="myToggleButton"



IsChecked, ElementName=myCheckBox, Mode=OneWay}"/>

<CheckBox x:Name="myCheckBox"



IsChecked, ElementName=myToggleButton, Mode=OneWay}"/>



  1. Check/uncheck the CheckBox, so the ToggleButton follows
  2. Click on the ToggleButton
  3. Now check/uncheck the CheckBox, the ToggleButton does not follow anymore!!!

Here, a TwoWay mode will be a workaround, but I am not interested since my IsItPossibleToNotReady property is read only.

Am I wrong or it is a XAML bug? Is there a XAML only workaround?



All Comments

Leave a comment...

    • There is some discussion of the issue in this thread: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=658462&SiteID=1

      But if you have a read-only property, why bind to a non read-only interface element? I would suggest setting IsEnabled="False" to prevent pressing the button, however, in doing so, the checked state is no longer visible.

      - Doug

      #1; Tue, 04 Sep 2007 00:36:00 GMT
    • AFAIK, what happens is that when u initially click on the toggle button the binding on the toggle button is proer but when u are setting the value on the checkbox the binding to the togglebutton is lost.. so when u click on the checkbox you are just setting thte value.... there is no binding to the button... this happens for only one way bindings...

      #2; Tue, 04 Sep 2007 00:37:00 GMT
    • Ok, it seems to be the same issue, but it sounds like a bug!!

      Thank you very much for your quick answer,


      #3; Tue, 04 Sep 2007 00:38:00 GMT
    • I also have this problem with one way binding before, and Ian Griffiths advices me to save binding before I set the value on the target, and restore the binding after I've done setting the value, although it's a solution, but I think it's too cumbersome, so finally I decide to define my read only property this way:
      public boolean IsSelected
      get {return isSelected;}
      set {/*NOP*/} // This just lets the two way data binding work.

      and I use the two way data binding here, any changes to the IsSelected property will be ignored, and it works perfectly

      #4; Tue, 04 Sep 2007 00:39:00 GMT