![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
| |
| | #1 (permalink) |
| | No CheckBox.CheckedChanged? It'd be nice if CheckBox had a CheckedChanged eventhandler instead of/in addition to the two separate Checked and Unchecked events. |
My System Specs![]() |
| | #2 (permalink) |
| | Re: No CheckBox.CheckedChanged? You lost me, wouldn't the binding go the other way? (e.g. if I changed the bound property the checkbox's checked state would change) "Michael Latta" wrote: > You can bind to the IsChecked property to get a method called with the > current value of the IsChecked property whenever it changes. > > Michael > (C# / WPF MVP) > http://spaces.msn.com/members/michaellatta > > "RyanLeeSchneider" <RyanLeeSchneider@discussions.microsoft.com> wrote in > message news:C74B1151-EE56-40BF-87CD-D91D3732DE27@microsoft.com... > > > > It'd be nice if CheckBox had a CheckedChanged eventhandler instead of/in > > addition to the two separate Checked and Unchecked events. > > > |
My System Specs![]() |
| | #3 (permalink) |
| | Re: No CheckBox.CheckedChanged? You can create a property that is bound to the IsChecked property of the control. When the user checks the check box your property setter will be invoked for bi-directional binding. You can place in the setter either your logic or a call to a method that will respond to the changes in state. Michael (C#/WPF MVP) http://spaces.msn.com/members/michaellatta "RyanLeeSchneider" <RyanLeeSchneider@discussions.microsoft.com> wrote in message news:A0AC8F75-F099-4E0A-B25A-15EF5A6ED928@microsoft.com... > > You lost me, wouldn't the binding go the other way? (e.g. if I changed the > bound property the checkbox's checked state would change) > > "Michael Latta" wrote: > >> You can bind to the IsChecked property to get a method called with the >> current value of the IsChecked property whenever it changes. >> >> Michael >> (C# / WPF MVP) >> http://spaces.msn.com/members/michaellatta >> >> "RyanLeeSchneider" <RyanLeeSchneider@discussions.microsoft.com> wrote in >> message news:C74B1151-EE56-40BF-87CD-D91D3732DE27@microsoft.com... >> > >> > It'd be nice if CheckBox had a CheckedChanged eventhandler instead >> > of/in >> > addition to the two separate Checked and Unchecked events. >> >> >> |
My System Specs![]() |
| | #4 (permalink) |
| | Re: No CheckBox.CheckedChanged? What I don't like about that is then my data object has UI-specific code in it. In my scenario, I'm using checkboxes to 'select' nodes of a treeview for batch-processing. The caveat is that the data objects I am bound to don't (and cannot because they are used in other projects) have references to the WinFX runtime. I'd like to use style triggers to highlight the nodes (bold if all childern are selected, italics if some, normal if none) ala the WPF folder picker sample from okoboji. However, I don't want to clutter up my 'pure' data objects with UI-specific properties. What would people suggest in that scenario? Currently, I'm thinking of having a 'shadow' heirarchical data object that contains the UI-specific properties for my treeview, and use a separate datasource to bind things like my checkbox to that. Sound reasonable? "Michael Latta" wrote: > You can create a property that is bound to the IsChecked property of the > control. When the user checks the check box your property setter will be > invoked for bi-directional binding. You can place in the setter either your > logic or a call to a method that will respond to the changes in state. > > Michael > (C#/WPF MVP) > http://spaces.msn.com/members/michaellatta > > "RyanLeeSchneider" <RyanLeeSchneider@discussions.microsoft.com> wrote in > message news:A0AC8F75-F099-4E0A-B25A-15EF5A6ED928@microsoft.com... > > > > You lost me, wouldn't the binding go the other way? (e.g. if I changed the > > bound property the checkbox's checked state would change) > > > > "Michael Latta" wrote: > > > >> You can bind to the IsChecked property to get a method called with the > >> current value of the IsChecked property whenever it changes. > >> > >> Michael > >> (C# / WPF MVP) > >> http://spaces.msn.com/members/michaellatta > >> > >> "RyanLeeSchneider" <RyanLeeSchneider@discussions.microsoft.com> wrote in > >> message news:C74B1151-EE56-40BF-87CD-D91D3732DE27@microsoft.com... > >> > > >> > It'd be nice if CheckBox had a CheckedChanged eventhandler instead > >> > of/in > >> > addition to the two separate Checked and Unchecked events. > >> > >> > >> > > > |
My System Specs![]() |
| | #5 (permalink) |
| | Re: No CheckBox.CheckedChanged? I think what Michael was suggesting was something like this: class MyDataObject { public bool Selected { set { ... } } } <CheckBox IsChecked="{Binding Path=Selected, Mode=OneWayToSource}" /> This doesn't place any dependencies to WPF in your model. But if you still want to keep this out of the model, then yes creating a shadow model is common practice. Effectively this is the ViewModel from the "Model View ViewModel" pattern that a few people have been throwing around. - Doug > What I don't like about that is then my data object has UI-specific > code in it. > > In my scenario, I'm using checkboxes to 'select' nodes of a treeview > for batch-processing. The caveat is that the data objects I am bound > to don't (and cannot because they are used in other projects) have > references to the WinFX runtime. > > I'd like to use style triggers to highlight the nodes (bold if all > childern are selected, italics if some, normal if none) ala the WPF > folder picker sample from okoboji. However, I don't want to clutter > up my 'pure' data objects with UI-specific properties. > > What would people suggest in that scenario? Currently, I'm thinking > of having a 'shadow' heirarchical data object that contains the > UI-specific properties for my treeview, and use a separate datasource > to bind things like my checkbox to that. Sound reasonable? > > "Michael Latta" wrote: > >> You can create a property that is bound to the IsChecked property of >> the control. When the user checks the check box your property setter >> will be invoked for bi-directional binding. You can place in the >> setter either your logic or a call to a method that will respond to >> the changes in state. >> >> Michael >> (C#/WPF MVP) >> http://spaces.msn.com/members/michaellatta >> "RyanLeeSchneider" <RyanLeeSchneider@discussions.microsoft.com> wrote >> in message news:A0AC8F75-F099-4E0A-B25A-15EF5A6ED928@microsoft.com... >> >>> You lost me, wouldn't the binding go the other way? (e.g. if I >>> changed the bound property the checkbox's checked state would >>> change) >>> >>> "Michael Latta" wrote: >>> >>>> You can bind to the IsChecked property to get a method called with >>>> the current value of the IsChecked property whenever it changes. >>>> >>>> Michael >>>> (C# / WPF MVP) >>>> http://spaces.msn.com/members/michaellatta >>>> "RyanLeeSchneider" <RyanLeeSchneider@discussions.microsoft.com> >>>> wrote in message >>>> news:C74B1151-EE56-40BF-87CD-D91D3732DE27@microsoft.com... >>>> >>>>> It'd be nice if CheckBox had a CheckedChanged eventhandler instead >>>>> of/in >>>>> addition to the two separate Checked and Unchecked events. |
My System Specs![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| how to create checkbox using vbscript | VB Script | |||
| Welcome Center - can't get rid of it (checkbox is missing!) | Vista installation & setup | |||
| Welcome Center - can't get rid of it (checkbox is missing!) | Vista General | |||
| Checkbox to never see this pop-up again. | Vista account administration | |||