如何访问Stackpanel子控件 [英] How to access Stackpanel child controls

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

问题描述

我在运行时创建文本框并向Stack面板添加相同的控件,这也是在运行时创建的。现在我需要让孩子控制堆栈面板....

I am creating textbox at runtime and adding same control to Stack panel which is also created at runtime. Now I need to get the child control of stack panel ....

任何人都可以帮助我....

can any one help me out....

谢谢Amar

推荐答案

这是代码

 Button buttonone=new Button();
            buttonone.Name = "buttonone";
            stackpanel.Children.Add(buttonone);

            //one way to access the first button in the lust
            Button button=(Button)stackpanel.Children.Where(i => i is Button).FirstOrDefault();


            // another way to check the name of the button to get it again
            foreach (Button b in stackpanel.Children.Where(i => i is Button))
            {
                if(b.Name=="buttonone")
                {

                }
            }

问候,


这篇关于如何访问Stackpanel子控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆