Thursday, 15 May 2014

c# - Firing an event when checkbox is checked for WPF -



c# - Firing an event when checkbox is checked for WPF -

what right way beingness checked in checkbox. have done far not firing event on checkbox items checked:

<listbox grid.rowspan="3" grid.column="2" grid.columnspan="5" margin="2" itemssource="{binding machinepositionlist}"> <listbox.itemtemplate> <hierarchicaldatatemplate> <checkbox content="{binding posid}" ischecked="{binding ischecked, mode=twoway}"> <i:interaction.triggers> <i:eventtrigger eventname="checked"> <i:invokecommandaction command="{binding currentcheckedposition}" /> </i:eventtrigger> </i:interaction.triggers> </checkbox> </hierarchicaldatatemplate> </listbox.itemtemplate> </listbox>

thanks lot :-).

you can utilize checked events:

<checkbox name="mycheckbox" content="i checkbox!" checked="mycheckbox_checked" unchecked="mycheckbox_unchecked" />

and code these events is:

private void mycheckbox_checked(object sender, routedeventargs e) { // ... } private void mycheckbox_unchecked(object sender, routedeventargs e) { // ... }

edit: noticed have content checkboxes "{binding posid}" can (as have list of check boxes) in checked events, have like:

if (sender != null) { int posid = convert.toint32(((checkbox)sender).name); }

this give "posid" , can need it. :d

c# wpf events checkbox

No comments:

Post a Comment