[IronPython] WPF Window vs. Application

Lukas Cenovsky cenovsky at bakalari.cz
Tue May 4 19:10:37 CEST 2010


Lukáš Duběda wrote:
> Hi there everybody.
>
> I have yet another question.
>
> This time, since I'm trying to strictly use WPF for my GUI
> etc... and what I do here is I host IronPython within another
> application that calls it and IPy serves the GUI and
> program logic, I bumped into a problem when calling the
>
> Application().Run(LoadedXaml)
>
> The problem seems to be that the app runs in its own thread
> separately from the host app and thus doesn't communicate
> with the host app, until I close the Application (then
> it performs the last task I wanted it to).
>
> So, I was thinking, since I already have most of the gory
> Application stuff already up and running, courtesy of the
> host app, is there a way to actually only use WPF to
> display the GUI and have the program logic taken care of by
> IPy? Such as WinForms provides using the Window.Show()
> method.
>
> A friend of mine suggested if I could change the Data Type
> of the XamlReader.Load... object to a Window object. I don't
> know C#, but he suggested this:
>
> Window myWindow;
> object result = XamlReader.Load( source );
> myWindow = (Window)result;
> myWindow.Show();
>
> Is this somehow achieveable via IPy scripting or directly in
> the Xaml? Or somehow else?

I doubt this would work - WinForms Window is not the same as WPF Window. 
I think you have to run you WPF app in background STA thread to be able 
to control in from the main thread.

--
-- Lukáš




More information about the Ironpython-users mailing list