I've been discussing how to load styles and new UI designs into an Avalon application, specifically focusing on the challenge of connecting the UI to the code-behind class when loading XAML at runtime. While the XAML loader can parse properties, it doesn't automatically handle event delegate generation and element naming like compiled code/BAML. One idea is to have UI designers create BAML, allowing the app to load new compiled XAML and use the same code-behind class. Another approach involves designing multiple layouts sharing the same code-behind class. I'm also exploring loading a XAML file with resources at runtime and assigning them dynamically. More to come on my findings!
I'm exploring ways to dynamically change the layout and styles of my Avalon application at runtime, allowing users to switch between different UI themes. I'm considering several approaches:
- Stylesheets: Can styles be stored externally and loaded dynamically? I've looked at DynamicResource but I'm unsure if it supports loading XAML from external files.
- Dynamic XAML Loading: Can I reload the XAML used by a window at runtime using LoadComponent? The _contentLoaded flag suggests this might not be possible.
- Restart on Style Change: A simpler but less desirable option is to require the application to restart when the user changes the UI style.
- Localization Analogy: Could the localization framework be adapted for loading different XAML files? I'm unsure if there's a connection between Resource Files and XAML resources.
I've been experimenting with the Microsoft Avalon CTP (Community Technology Preview) Framework and wanted to share a simple XAML menu example. This example demonstrates how to create a custom style for menu items to make them look like GelButtons. Initially, I tried using a ControlTemplate but later realized a HeaderTemplate within the style was the correct approach. The XAML code provided creates a menu with styled menu items, showcasing how to customize the appearance and behavior of menu items in Avalon.