サーバ側にxamlpythonスクリプトをおき、クライアント側でそれらをdownloadして連結するテスト。
あっさり、動いた。

前記の開発環境にIronPython1.1を追加。



using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.IO;
using System.Net;
using System.Windows;
using System.Windows.Markup;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Navigation;

// IronPython1.1
using IronPython.Hosting;
using IronPython.Runtime;


namespace ConsoleApplication1
{
class pythonTest
{
[STAThread]
public static void Main(string[] args)
{
System.Net.WebClient client = new WebClient();
Byte [] data = client.DownloadData( "http://localhost/Window1.xaml" );
MemoryStream st = new MemoryStream( data );

Window mainwnd = (Window)XamlReader.Load( st );
mainwnd.Height = 480;
mainwnd.Width = 640;
mainwnd.Title = "hoi";

// -----------------------------------------------------

PythonEngine py = new PythonEngine ();

py.Globals["mainwnd"] = mainwnd;

data = client.DownloadData( "http://localhost/test.py" ); // <--IronPython Script

string script = System.Text.Encoding.GetEncoding("shift_jis").GetString( data, 0, data.Length );

py.Execute( script );

Application ap = new Application();
ap.Run( mainwnd );
}
}
}

で下がそのptython script、test.py。


import clr
clr.AddReferenceByPartialName("PresentationCore")
clr.AddReferenceByPartialName("PresentationFramework")
from System.Windows import *


def ButtonClick( sender, event):
MessageBox.Show ('I am Python')

btn = mainwnd.FindName( "button1" );
btn.Click += ButtonClick