我在listview控件中有复选框。我想找到里面的复选框控件名称 这样的列表视图 for( int k = 0; k< = listView1.Items.Count - 1; k ++) { ListViewData lvc =(ListViewData)listView1.Items [k]; 选项1:var chb_standard =发送者作为CheckBox; option2:CheckBox myTextbox = GetTemplateChild(chb_standard)作为CheckBox; checkBox.IsChecked = true; } 但我无法引用复选框控件名称我只得到null是否有任何想法 参考控制帮助我。提前谢谢
i am having checkbox inside listview control .i want to find the checkbox control name inside list view like this for (int k = 0; k <= listView1.Items.Count - 1; k++) { ListViewData lvc = (ListViewData)listView1.Items[k]; option 1: var chb_standard = sender as CheckBox; option2: CheckBox myTextbox = GetTemplateChild("chb_standard") as CheckBox; checkBox.IsChecked = true; } but i can't able to refer the checkbox control name i am getting only null is there any idea to refer the control help me. thanks in advance
推荐答案请参阅: http ://msdn.microsoft/en-us/library/ms753391.aspx [ ^ ]。 此CodeProject文章也很有用:了解WPF中的可视树和逻辑树 [ ^ ]。
有几种辅助方法 GetVisualChildren 和 GetVisualDescendants 可用于访问控件中的子元素。 There are a couple of helper methods GetVisualChildren and GetVisualDescendants that you could use to access child elements inside a control.
更多推荐
如何在wpf中引用子控件
发布评论