用户控件按钮单击事件

问题描述:

大家好......

我正在使用具有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.