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) {return;}_contentLoaded = true;System.Uri resourceLocator =new System.Uri("Window1.baml",System.UriKind.RelativeOrAbsolute);System.Windows.Application.LoadComponent(this,resourceLocator);}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.-Or-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 ;) )
I lead the Chrome Developer Relations team at Google.
We want people to have the best experience possible on the web without having to install a native app or produce content in a walled garden.
Our team tries to make it easier for developers to build on the web by supporting every Chrome release, creating great content to support developers on web.dev, contributing to MDN, helping to improve browser compatibility, and some of the best developer tools like Lighthouse, Workbox, Squoosh to name just a few.
I love to learn about what you are building, and how I can help with Chrome or Web development in general, so if you want to chat with me directly, please feel free to book a consultation.
I'm trialing a newsletter, you can subscribe below (thank you!)