[IronPython] How implement INotifyPropertyChanged?

Jun 26, 2008 at 1:44 PM
Edited Jun 27, 2008 at 8:13 AM
I try
class NotifyImplementation(INotifyPropertyChanged):
    def __init__(self):
    def Test(self):
        self.OnPropertyChanged(self, PropertyChangedEventArgs("test property changed"))

def TestHandler(obj, e):
    print type(e.PropertyName)

a = NotifyImplementation()
a.PropertyChanged += TestHandler

But it doesn't work. Is there any working sample implement interface with event on DLR languages?
Jun 12, 2009 at 7:25 PM

from System.ComponentModel import *
from pyevent import *

class NotifyPropertyChanged(INotifyPropertyChanged):
    PropertyChanged = None

    def __init__(self):
        (self.PropertyChanged, self._propertyChangedCaller) = make_event()

    def add_PropertyChanged(self, value):
        self.PropertyChanged += value

    def remove_PropertyChanged(self, value):
        self.PropertyChanged -= value
    def OnPropertyChanged(self, propertyName):
        self._propertyChangedCaller(self, PropertyChangedEventArgs(propertyName))

Jun 15, 2009 at 11:19 PM
Edited Jun 15, 2009 at 11:19 PM

I'm getting "no module named pyevent" when calling Execute on the scope for that code. What am I missing to get that module in my SL3 app?

Thank you.

Jun 16, 2009 at 10:36 AM




Jun 16, 2009 at 4:22 PM

Thanks for the tip on pyevent. Got it from codeplex. Looking at the examples there, it seems it will resolve it because it is in the same folder as the executing exe. However, that's all different with SL and XAPs. So, I added it with a build action of Content and then prior to executing the above script it CreateScriptFromFile("pyevent.py") and compile it and it seems to resolve fine now.  "It compiles, let's ship!". :)  I just wanted to make sure that's the right process to get the pyevent referenceable from the other script.

Thanks again.