怎么在C#代码里关联button的点击事件?
怎么关联动态创建的button的eventhandler?这是我用的代码:publicpartialclassMainPage:PhoneApplicationPage{...
怎么关联动态创建的button的event handler?这是我用的代码:public partial class MainPage : PhoneApplicationPage{ Button AddButton public MainPage() { CreateInterestEntry(); } private void CreateInterestEntry() { EntrySegment = getEntrySegment(); ContentPanel.Children.Add(EntrySegment); } private void AddButton_Click(Object sender, RoutedEventArgs e) { //Stuff to do when button is clicked } private Grid getEntrySegment() { Grid EntrySegment = new Grid(); //Creating the grid goes here AddButton = new Button(); AddButton.Content = "Add"; AddButton.Click += new EventHandler(AddButton_Click); return EntrySegment; }}}这个代码编译提示“no overload for AddButton_Click matches delegate "System.EventHandler".”有什么解决办法吗?
展开
1个回答
2013-08-22
展开全部
试试这个:AddButton.Click += new RoutedEventHandler(AddButton_Click);添加Click Event Handler:void AddButton_Click(object sender, RoutedEventArgs e){}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询