I'd hope using Application.LoadComponent would work better =)
> -----Original Message----- > From: [EMAIL PROTECTED] [mailto:users- > [EMAIL PROTECTED] On Behalf Of Dan Eloff > Sent: Sunday, May 11, 2008 7:38 AM > To: Discussion of IronPython > Subject: Re: [IronPython] StaticResources + DLR + Silverlight > > Ok, I think I have discovered an answer to this one. I haven't tested > it because I no longer use xaml files for anything but resources, but > it *should* work. Make a xaml file for just application level > resources, it should simply consist of a <ResourceDictionary>. Use > XamlReader.Load() to read it, now you have a dictionary of your global > styles and things. Programmatically merge that dictionary into the > Application.Current.Resources dictionary. If that works, you should be > able to use {StaticResource } to refer to your resources from > anywhere. > > But bottom line is XAML cannot use Python objects and controls, so for > anything but the very simple, it soon becomes a liability. I've made a > module that simplifies the process of creating controls in Python > (which I hope to place in the IronPython cookbook soon.) > > Here's an example: > > x.Canvas(Width=400, Height=400)( > x.Rectangle(Width=200, Height=200, Canvas_Top=100, Canvas_Left=100, > > Fill=x.VerticalGradient([(x.Colors.DarkTurquoise, 0), > (x.Color('#4169e1'), 1)]) > ) > > It's about half the size of the equivalent xaml, but no static error > checking, and very little in the way of auto completion and > intellisense, so I consider it about a wash. The advantage is that you > can now use Python controls and objects, and you can use anything > python has to offer, like loops, closures, or conditionals, when > constructing your interface. > > -Dan > > On Tue, May 6, 2008 at 2:04 AM, Jimmy Schementi > <[EMAIL PROTECTED]> wrote: > > Dan, > > > > It's a very good question, and I'm a little embarrassed not to have a > solution for you. Give me some time to poke around and find the best > way to do this. > > > > ~js > > > >> -----Original Message----- > >> From: [EMAIL PROTECTED] [mailto:users- > >> [EMAIL PROTECTED] On Behalf Of Dan Eloff > >> Sent: Monday, May 05, 2008 6:44 AM > >> To: Discussion of IronPython > >> Subject: [IronPython] StaticResources + DLR + Silverlight > >> > >> I notice if you use C#/VB, you have <Application> in your main xaml > >> file. In there you can place resources that can be used from > anywhere > >> in your other xaml files. Using the {StaticResource foo} markup > >> extension. > >> > >> If you are using a dynamic language, there is no > <DynamicApplication> > >> equivalent (please correct me if I'm wrong), most examples I've seen > >> use <UserControl>. > >> > >> The trouble is placing your resources in <UserControl.Resources> > makes > >> them off limit to {StaticResource foo} in any other xaml files > (again > >> please correct me if I'm wrong) > >> > >> So I find myself in a nightmare of duplicating resources across > files > >> and setting styles in code from > >> Application.Current.RootVisual.Resources['foo'], neither of which is > >> pleasant. Are there really no better alternatives? > >> > >> -Dan > >> _______________________________________________ > >> Users mailing list > >> [email protected] > >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > _______________________________________________ > > Users mailing list > > [email protected] > > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > _______________________________________________ > Users mailing list > [email protected] > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com _______________________________________________ Users mailing list [email protected] http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
