我有一个带有checkBox的ListBox.ItemTemplate。我不知道如何查找或设置检查选项 [英] I have a ListBox.ItemTemplate with a checkBox. I do not know how to find or set the check options
问题描述
我可以获取项目,我可以找到除checkBox选中的值之外的所有项目。当项目被选中时,我想知道是否选中了复选框。
<! - 这是列表框 - >
< listbox name =lbTodoListgrid.row =3removed =AliceBluehorizontalcontentalignment =Stretchselectionchanged =lbTodoList_SelectionChangedkeydown =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 =chkBoxfontweight =Boldcontent ={Binding TrackRace}checked =chkBox_Checkedxmlns:x =#unknown>
< textblock grid.column =1fontweight =Boldhorizontalalignment =Righttext ={Binding RaceTime}>
/>
< ; textblock grid.row =1text ={Binding RaceDist}>
< textblock grid.row =1grid.column =1horizontalalignment =righttext ={Binding RaceClass}>
这是h我得到项目数据
foreach(lbTodoList.SelectedItems中的对象o)
{(o as TodoItem).TrackRace}但它只给了我Bel#的值6不是如果盒子被检查了。
我希望这很清楚。
谢谢Ray:
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:
推荐答案
参考:如何获取已检查的行列表值列表视图-wpf [ ^ ]
这篇关于我有一个带有checkBox的ListBox.ItemTemplate。我不知道如何查找或设置检查选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!