views:

62

answers:

1

Hi,

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).

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?

TIA... Sudeep

A: 

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.

Joachim Kerschbaumer
Hi Joachim, I tried checking this approach. What exactly should I be looking for in the callstack? Presently in my callstack I can see "[Native to Managed Transition]" as the previous stack member.
Sudeep