. Topicala Page Index Token

A Journal about the experiences I have developing little applications in C#, Perl, Html and Javascript and talking about things new things that I use. Always Geeky; Always Nerdy; Always poor Grammer!

I am a Software Analyst Developer working in Southport, England but living in Liverpool. I develop mainly in C# and ASP.Net. I have been developing comercial software for several years now. I maintain this site (hosted at SwitchMedia UK) as a way of exploring new technologies (such as AJAX) and just generally talking about techie geek issues. This site is developed through a host of Perl scripts and a liberal use of Javascript. I enjoy experimenting with new technologies and anything that I make I host here.

Quick Search

Web www.kinlan.co.uk

Friday, June 10, 2005

Changing Styles with the times

I have been thinking and looking into whether I should code up what I am thinking, I would like to pass it by you guys to see if it is possible or has been done before (or if there is an easier way).

Basically my thoughts have been these:
In Avalon, is it possible to completely change the layout and styles at runtime such that I could have "n" different layouts to the same app, all of which are loaded as requested by the user? What I mean by completely change, is not only adjusting colours and graphical styling, but also adjusting ContentTemplates, HeaderTemplates and positioning in the Logical Tree. Would it be possible to have one "Style" that is based around, say, a DockPanel and another around a Grid Panel each can be loaded and alternated between at runtime, but have the Backend Business Logic remain untouched?

In essence I would like to switch from one XAML based front-end to another XAML based front end. Without affecting the application.

My First thought was, could I achieve this with a style sheet system, so I investigated the Styles property in Avalon and I couldn't determine if the styles could be stored in an external resource, such as a styles folder which contains all the different styles. Can the styles be stored in an external resource?

I did however see some threads (most specifically "How Do I - Resource-Style Questions") which pointed me towards <button style="DynamicResource: ">..</button> I was thinking this would enable me to keep the logical tree static but just change things such as colours, widths and the visual tree of certain components based on configuration options. But I am not too sure if this is what I am aiming for. I could configure colours and widths etc, but I don't think they could be bound to XAML (i.e loaded from a file).

My second thought was can we change the XAML file that the system uses at runtime? I have noticed some code in InitializeComponent of the window which sets which compiled XAML file to use:

public void InitializeComponent() {
if (_contentLoaded) {
_contentLoaded = true;
System.Uri resourceLocator =
new System.Uri("Window1.baml",

Could I basically re-call LoadComponent at any point in the app to change the UI based on another BAML file that user specifies. I assume we are not able too because _contentLoaded seems to be there to catch cases like this where InitializeComponent gets called more than once.
Thirdly, Could I just have the URI as an item that is read in at init time, and when the user wants to change their UI they have to restart the application.

Fourthly, I thought that localisation might be similar to what I need, each language is compiled into a Resource that can be built into the assembly or referenced externally. However due to my lack of experience I thought that there might be a correlation between a Resource File and the resources in a XAML file (Page.Resources/Application.Resources) but I have not been able to determine if they are one and the same thing or completely different. So I am not aware that I could reference the resources externally in a XAML file from a ResourceFile (see thought 1 ;) )

Comments: [Add New]