<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
        {mso-style-priority:99;
        mso-style-link:"Plain Text Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:10.5pt;
        font-family:Consolas;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.PlainTextChar
        {mso-style-name:"Plain Text Char";
        mso-style-priority:99;
        mso-style-link:"Plain Text";
        font-family:Consolas;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoPlainText>Dear Group,<o:p></o:p></p>

<p class=MsoPlainText><o:p>&nbsp;</o:p></p>

<p class=MsoPlainText>I have a rather involved question (more accurately series
of questions) regarding WPF, particularly how it relates to DataBinding and
DataTemplates.&nbsp; I will do my best to keep this posting to a reasonable length,
but ... well ... I guess this serves somewhat as a warning ;)&nbsp; If you will
spare me a bit of background, I recently began trying to learn IronPython after
hearing an enthusiastic endorsement from a friend and colleague.&nbsp; While not a
programmer or computer scientist by training (on the opposite of the spectrum,
actually, my degree is in biomedical engineering); I have found myself
increasing needing to work with programming tools in the past few years.&nbsp; This
friend pointed me toward the .Net framework, and IronPython in particular as a
potential solution to several major issues we have been facing with our primary
data processing tool: Matlab.<o:p></o:p></p>

<p class=MsoPlainText><o:p>&nbsp;</o:p></p>

<p class=MsoPlainText>As a trial test, I therefore decided to create a small
program in IronPython, namely, a Podcast Aggregator.&nbsp; I purchased a Manning
Early Access Program copy of Michael Foord's (excellent BTW) book, IronPython
in Action and started trying to work toward my small test project.&nbsp; As I also
wanted to learn WPF (not to mention make my little program as pretty as
possible), I decided to write the user interface for my aggregator in .xaml.<o:p></o:p></p>

<p class=MsoPlainText><o:p>&nbsp;</o:p></p>

<p class=MsoPlainText>So, with that background out of the way, I arrive at a
few questions.&nbsp; The first of these is somewhat of a follow-up to a topic
addressed in May on this very list somewhat recently (reference: <a
href="http://lists.ironpython.com/pipermail/users-ironpython.com/2007-May/004912.html">http://lists.ironpython.com/pipermail/users-ironpython.com/2007-May/004912.html</a>).&nbsp;
In the original post, the author (Bish Bosh) asked what the best method of
referring to Python types in Xaml was.&nbsp; Later in the discussion, Dino Viehland
offered that it might be best to:<o:p></o:p></p>

<p class=MsoPlainText><o:p>&nbsp;</o:p></p>

<p class=MsoPlainText>&quot;Declare an interface in C# (or find an existing one
which has what you want) and inherit and implement the interfaces in Python.&nbsp;
Then the interface will be the bridge between the static and dynamic
worlds&quot; (reference: <a
href="http://lists.ironpython.com/pipermail/users-ironpython.com/2007-May/004913.html">http://lists.ironpython.com/pipermail/users-ironpython.com/2007-May/004913.html</a>).<o:p></o:p></p>

<p class=MsoPlainText><o:p>&nbsp;</o:p></p>

<p class=MsoPlainText>So, my first question: After reading all the material I
have been able to find on the subject, I have not been able to locate a good
tutorial or example of how this might be done.&nbsp; Might it be possible to get
some additional information on how this can be accomplished?&nbsp; A simple example
of how it can then be integrated into IronPython code would be extremely
appreciated.<o:p></o:p></p>

<p class=MsoPlainText><o:p>&nbsp;</o:p></p>

<p class=MsoPlainText>I have made an effort using the information available in
the IronPython tutorial and a relatively simple XAML example (reference: <a
href="http://blah.winsmarts.com/2007-3-WPF__The_DataTemplate,_choosing_how_your_data_will_look_like.aspx">http://blah.winsmarts.com/2007-3-WPF__The_DataTemplate,_choosing_how_your_data_will_look_like.aspx</a>),
but I have had no luck in creating a test application that will successfully
load and perform as advertised.<o:p></o:p></p>

<p class=MsoPlainText><o:p>&nbsp;</o:p></p>

<p class=MsoPlainText>Using the xaml, C# and mainWindow.py file below, I
receive the error:<o:p></o:p></p>

<p class=MsoPlainText><o:p>&nbsp;</o:p></p>

<p class=MsoPlainText>SystemError: Type reference cannot find public type named
'LocalTimes'<o:p></o:p></p>

<p class=MsoPlainText><o:p>&nbsp;</o:p></p>

<p class=MsoPlainText>I am at the end of my rope and am not sure what I should
try next.&nbsp; Are there any ideas on how I might successfully implement a custom
C# interface?<o:p></o:p></p>

<p class=MsoPlainText><o:p>&nbsp;</o:p></p>

<p class=MsoPlainText>Sincerely,<o:p></o:p></p>

<p class=MsoPlainText><o:p>&nbsp;</o:p></p>

<p class=MsoPlainText>Rob Oakes<o:p></o:p></p>

<p class=MsoPlainText><o:p>&nbsp;</o:p></p>

<p class=MsoPlainText>PS, Here is the source code for the simple test case I
have been working with.<o:p></o:p></p>

<p class=MsoPlainText><o:p>&nbsp;</o:p></p>

<p class=MsoPlainText>&lt;&lt; Main IPY script, called from command line with
ipy TestApp.py<o:p></o:p></p>

<p class=MsoPlainText><o:p>&nbsp;</o:p></p>

<p class=MsoPlainText>import clr<o:p></o:p></p>

<p class=MsoPlainText>import os<o:p></o:p></p>

<p class=MsoPlainText>import WindowsRSS<o:p></o:p></p>

<p class=MsoPlainText>clr.AddReference(&quot;PresentationFramework&quot;)<o:p></o:p></p>

<p class=MsoPlainText>clr.AddReference(&quot;PresentationCore&quot;)<o:p></o:p></p>

<p class=MsoPlainText>clr.AddReferenceToFile(&quot;IFancyData.dll&quot;)<o:p></o:p></p>

<p class=MsoPlainText><o:p>&nbsp;</o:p></p>

<p class=MsoPlainText>import LocalTimes, LocalTime<o:p></o:p></p>

<p class=MsoPlainText><o:p>&nbsp;</o:p></p>

<p class=MsoPlainText>from System.IO import File<o:p></o:p></p>

<p class=MsoPlainText>from System.Windows.Markup import XamlReader from
System.ComponentModel import INotifyPropertyChanged from System.ComponentModel
import PropertyChangedEventArgs from System.Windows import Application, Window<o:p></o:p></p>

<p class=MsoPlainText><o:p>&nbsp;</o:p></p>

<p class=MsoPlainText>class TestApp(object):<o:p></o:p></p>

<p class=MsoPlainText><o:p>&nbsp;</o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp; def __init__(self):<o:p></o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xamlStream =
File.OpenRead('DataBinding_20081102.xaml')<o:p></o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.Root = XamlReader.Load(xamlStream)<o:p></o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.LocalTimes = LocalTimes()<o:p></o:p></p>

<p class=MsoPlainText><o:p>&nbsp;</o:p></p>

<p class=MsoPlainText>mainWin = TestApp()<o:p></o:p></p>

<p class=MsoPlainText>app = Application()<o:p></o:p></p>

<p class=MsoPlainText>app.Resources.Add('collection', LocalTimes())<o:p></o:p></p>

<p class=MsoPlainText>app.Run(mainWin.Root)<o:p></o:p></p>

<p class=MsoPlainText><o:p>&nbsp;</o:p></p>

<p class=MsoPlainText>&gt;&gt;<o:p>&nbsp;</o:p></p>

<p class=MsoPlainText><o:p>&nbsp;</o:p></p>

<p class=MsoPlainText>&lt;&lt; DataBinding_20081102.xaml - GUI Window<o:p></o:p></p>

<p class=MsoPlainText><o:p>&nbsp;</o:p></p>

<p class=MsoPlainText>&lt;Window xmlns=&quot;<a
href="http://schemas.microsoft.com/winfx/2006/xaml/presentation">http://schemas.microsoft.com/winfx/2006/xaml/presentation</a>&quot;<o:p></o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp; xmlns:x=&quot;<a
href="http://schemas.microsoft.com/winfx/2006/xaml">http://schemas.microsoft.com/winfx/2006/xaml</a>&quot;<o:p></o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp; Title=&quot;Hello World!&quot; Height=&quot;300&quot;
Width=&quot;300&quot;&gt;<o:p></o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Window.Resources&gt;<o:p></o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;ObjectDataProvider
x:Key=&quot;localTimes&quot; ObjectType=&quot;{x:Type LocalTimes}&quot;/&gt;<o:p></o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/Window.Resources&gt;<o:p></o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Grid&gt;<o:p></o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/Grid&gt;<o:p></o:p></p>

<p class=MsoPlainText>&lt;/Window&gt;<o:p></o:p></p>

<p class=MsoPlainText><o:p>&nbsp;</o:p></p>

<p class=MsoPlainText>&gt;&gt;<o:p>&nbsp;</o:p></p>

<p class=MsoPlainText><o:p>&nbsp;</o:p></p>

<p class=MsoPlainText>&lt;&lt; LocalTimes.cs - Custom C# Class - LocalTimes<o:p></o:p></p>

<p class=MsoPlainText><o:p>&nbsp;</o:p></p>

<p class=MsoPlainText>using System;<o:p></o:p></p>

<p class=MsoPlainText>using System.Collections;<o:p></o:p></p>

<p class=MsoPlainText>using System.Collections.Generic;<o:p></o:p></p>

<p class=MsoPlainText><o:p>&nbsp;</o:p></p>

<p class=MsoPlainText>public class LocalTimes : List&lt;LocalTime&gt; {<o:p></o:p></p>

<p class=MsoPlainText><o:p>&nbsp;</o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public LocalTimes() {<o:p></o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.Add(new LocalTime(&quot;New York&quot;,
DateTime.Now));<o:p></o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.Add(new LocalTime(&quot;Chicago&quot;,
DateTime.Now.AddHours(-1)));<o:p></o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.Add(new LocalTime(&quot;Denver&quot;,
DateTime.Now.AddHours(-2)));<o:p></o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.Add(new LocalTime(&quot;Los
Angeles&quot;, DateTime.Now.AddHours(-3)));<o:p></o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<o:p></o:p></p>

<p class=MsoPlainText>}<o:p></o:p></p>

<p class=MsoPlainText><o:p>&nbsp;</o:p></p>

<p class=MsoPlainText>public class LocalTime {<o:p></o:p></p>

<p class=MsoPlainText><o:p>&nbsp;</o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private string place;<o:p></o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private DateTime time;<o:p></o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <o:p></o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public LocalTime(string _place, DateTime _time) {<o:p></o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <o:p></o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; place = _place;<o:p></o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; time = _time;<o:p></o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<o:p></o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <o:p></o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public DateTime Time {<o:p></o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get { return time; }<o:p></o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set { time = value; }<o:p></o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<o:p></o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <o:p></o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public string Place {<o:p></o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <o:p></o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get { return place; }<o:p></o:p></p>

<p class=MsoPlainText>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<o:p></o:p></p>

<p class=MsoPlainText>}<o:p></o:p></p>

<p class=MsoPlainText><o:p>&nbsp;</o:p></p>

<p class=MsoPlainText>&gt;&gt;<o:p>&nbsp;</o:p></p>

<p class=MsoPlainText><o:p>&nbsp;</o:p></p>

<p class=MsoPlainText>Interpreter Output from the above files:<o:p></o:p></p>

<p class=MsoPlainText><o:p>&nbsp;</o:p></p>

<p class=MsoPlainText>&nbsp; File C:\Users\Rob
Oakes\AppData\IronPython\IPy-Tutorial\TestApp_20081102.py, line 23, in
Initialize<o:p></o:p></p>

<p class=MsoPlainText>&nbsp; File C:\Users\Rob
Oakes\AppData\IronPython\IPy-Tutorial\TestApp_20081102.py, line 20, in __init__<o:p></o:p></p>

<p class=MsoPlainText>&nbsp; File , line 0, in Load##106<o:p></o:p></p>

<p class=MsoPlainText>&nbsp; File PresentationFramework, line unknown, in Load<o:p></o:p></p>

<p class=MsoPlainText>&nbsp; File PresentationFramework, line unknown, in
XmlTreeBuildDefault<o:p></o:p></p>

<p class=MsoPlainText>&nbsp; File PresentationFramework, line unknown, in Parse<o:p></o:p></p>

<p class=MsoPlainText>&nbsp; File PresentationFramework, line unknown, in
ParseFragment<o:p></o:p></p>

<p class=MsoPlainText>&nbsp; File PresentationFramework, line unknown, in _Parse<o:p></o:p></p>

<p class=MsoPlainText>&nbsp; File PresentationFramework, line unknown, in ReadXaml<o:p></o:p></p>

<p class=MsoPlainText>&nbsp; File PresentationFramework, line unknown, in Read<o:p></o:p></p>

<p class=MsoPlainText>SystemError: Type reference cannot find public type named
'LocalTimes'.<o:p></o:p></p>

</div>

</body>

</html>