用户控件按钮单击事件 [英] Usercontrol button click events

查看:137
本文介绍了用户控件按钮单击事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好......

我正在使用具有2个标签和1个按钮的用户控件.我使用listbox.Itemtemplet在我的主页上显示此用户控件,这使我的用户控件显示我的iteamsource包含的时间....在我的情况下,该用户控件被创建了6次

但是这里的事情是我在用户控件中的按钮应该具有在列表框中加载的事件多次,以便我可以在代码隐藏中编写一些代码...我认为应该与之接近....

hello guys....

I am using a user control which has 2 labels and 1 button. And this user control I am displaying in my main page using listbox.Itemtemplet which makes my user control to show number of time my iteamsource contains ....in my case usercontrol is created for 6 times

But thing here is my button in user control should have events as many times as it loads in my listbox so that I can write some code in codebehind... I think there should be something close to this....

 public eventHandler  buttonclick;
        public  usercontrol()
        {
            
            InitializeComponent();
testButton.Click +=(s,e) =>
          {
         if(buttonclick != null )
          buttonclick(s,e);
         };



请帮我,我找不到任何解决方法...



please help me I dint find any solution...

推荐答案

您可以在xaml中的按钮控件中添加事件处理程序.
You can add an event handler to the button control in the xaml.


这篇关于用户控件按钮单击事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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