<div dir="ltr">You have to decorate the methods you want to expose to .net with the clrmethod decorator, e.g.<div><br></div><div>class MyClass(IInterface):</div><div>    @clrmethod(int, [str])</div><div>    def overridden_method(self, x):</div><div>        return len(x)</div><div><br></div><div>The parameters to the clrmethod decorator are the method return type and argument types. You can expose properties similarly using the clrproperty decorator.</div><div><span style="line-height:1.5"><br></span></div><div><span style="line-height:1.5">See runtime/resources/clr.py for details.</span></div><div><br></div><div>regards,</div><div>Tony</div><div>   </div></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Mar 16, 2016 at 9:29 PM Hansong Huang <hhspiny@pine.cc> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">This might be an obvious problem out of my lack of understanding how Python.Net work.<div><br></div><div>I am exploring the possibility of program WPF ViewModel.</div><div><br></div><div>After resolving the problem inheriting .Net interface class, </div><div><br></div><div><div>class ViewModel(System.ComponentModel.INotifyPropertyChanged):</div><div>    __namespace__ = "WPFPy"<br></div></div><div>....</div><div><br></div><div>class MyViewModel(ViewModel):</div><div>....  here to implement follow ironpython examples</div><div><br></div><div>then assign it to DataContext </div><div><br></div><div>self.window = System.Windows.Markup.XamlReader.Load(outStream)</div><div>self.window.DataContext = MyViewModel()</div><div><br></div><div>this does not seem to work, the property/method in MyViewModel is never called nor any data binding happened. </div><div><br></div><div>I was able to get ExpandoObject work well though and binding works fine </div><div>self.window.DataContext = System.Dynamic.ExpandoObject()</div><div><br></div><div>so, that makes me asking if it makes sense at all to pass a Python class object back into .Net framework and expect it works -- even if the proper interface is implemented. </div><div><br></div><div><br></div><div>thanks</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div>
_________________________________________________<br>
Python.NET mailing list - <a href="mailto:PythonDotNet@python.org" target="_blank">PythonDotNet@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/pythondotnet" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/pythondotnet</a></blockquote></div>