[IronPython] How implement INotifyPropertyChanged?

Jun 26, 2008 at 2:44 PM
Edited Jun 27, 2008 at 9: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 8: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 16, 2009 at 12:19 AM
Edited Jun 16, 2009 at 12:19 AM

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 11:36 AM




Jun 16, 2009 at 5: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.