如何在wpf中引用子控件

如何在wpf中引用子控件

本文介绍了如何在wpf中引用子控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在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

推荐答案



这篇关于如何在wpf中引用子控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 22:38