Click here to Skip to main content
15,897,226 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I can get items into and I can find all the items except the checkBox checked value. When the item is selected I would like to know if the checkBox is checked.

<!-- This is the listbox-->
<listbox name="lbTodoList" grid.row="3" removed="AliceBlue" horizontalcontentalignment="Stretch" selectionchanged="lbTodoList_SelectionChanged" keydown="lbTodoList_KeyDown"> <listbox.itemtemplate> <datatemplate>
<grid margin="1,2,2,0">
<grid.columndefinitions>
<columndefinition width="*"> <columndefinition width="Auto">
<grid.rowdefinitions>
<rowdefinition>
<rowdefinition>

<checkbox x:name="chkBox" fontweight="Bold" content="{Binding TrackRace}" checked="chkBox_Checked" xmlns:x="#unknown">
<textblock grid.column="1" fontweight="Bold" horizontalalignment="Right" text="{Binding RaceTime}">
/>
<textblock grid.row="1" text="{Binding RaceDist}">
<textblock grid.row="1" grid.column="1" horizontalalignment="Right" text="{Binding RaceClass}">


This is how I get the item data
foreach (object o in lbTodoList.SelectedItems)
{(o as TodoItem).TrackRace} but it just gives me the value "Bel #6" not if the box is checked or not.

I hope this is clear.
Thanks Ray:
Posted
Comments
[no name] 16-Jul-14 20:07pm    
If you come back and read your "question" do you think that it is clear?
Francisco T. Chavez 16-Jul-14 20:15pm    
I think you might want to rethink your solution a bit. The CheckBox's IsChecked property should be bound to a property within the item you are templating (your TodoItem instance). This way, you only need to check the value of that property in your item, not the value of each CheckBox. One of the nice things about WPF is the seperation of the data from the UI. This doesn't always work (like in the case of the selected items property), but it does a really good job at it.

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900