I am developing a Silverlight 3 application, in which I have a boolean property in my Model class (using MVVM approach) that's bound to "IsEnabled" target property of two buttons. I need to find out which button invoked this boolean property when I raise the PropertyChanged event (i.e. during databinding).
我正在开发一个Silverlight 3应用程序,其中我的Model类中有一个布尔属性(使用MVVM方法),它绑定到两个按钮的“IsEnabled”目标属性。当我引发PropertyChanged事件时(即在数据绑定期间),我需要找出哪个按钮调用了这个布尔属性。
Is there something in the callstack that I can look for to figure this out? Or is there some other way by which I can do this?
在callstack中有什么东西我可以找到来解决这个问题吗?或者还有其他方法可以做到这一点吗?
TIA... Sudeep
You could check the call stack e.g.
您可以检查调用堆栈,例如
var st = new System.Diagnostics.StackTrace();
var callingtypeOfAMethod = st.GetFrame(1).GetMethod().DeclaringType;
i hope this gets you the idea. you can get the calling control type using this.
我希望这会让你有这个想法。您可以使用此方法获取调用控件类型。
本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.silva-art.net/blog/2009/06/22/35aa9bca5f49e547fa9637e2e35b2403.html。