在wpf中动态添加事件的问题 [英] Problem in dynamically adding event in wpf

查看:76
本文介绍了在wpf中动态添加事件的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我使用以下代码将woding行事件添加到wpf中的datagrid





Hi Im using following code to add loding row event to datagrid in wpf


grdpurchase.LoadingRow += new EventHandler<DataGridRowEventArgs>(grdpurchase_LoadingRow);
            grdpurchase.ItemsSource = arr;//ArrayList
            grdpurchase.LoadingRow -= new EventHandler<DataGridRowEventArgs>(grdpurchase_LoadingRow);





但是添加项目来源后无法正常工作请帮我解决问题

我正在使用C#



but This is not working after add the item source please help me to solve tis issue
Im using C#

推荐答案

我认为您的附加订购和分离可能成为这里的Problamatic。在理想情况下它应该首先分离然后附加事件。你在完成它时完全反向。请通过更改以下代码来考虑这个事实来检查它。





I think your Ordering of Attaching and Detaching Might become Problamatic Here. In Ideal Situation It should be Detaching First and then attaching the event.Where as You had done it Totally Reverse. Please Check it by Considering this facts by Changing code as below.


 grdpurchase.LoadingRow -= new EventHandler<DataGridRowEventArgs>(grdpurchase_LoadingRow);
grdpurchase.LoadingRow += new EventHandler<DataGridRowEventArgs>(grdpurchase_LoadingRow);
 grdpurchase.ItemsSource = arr;//ArrayList


这篇关于在wpf中动态添加事件的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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