Recently on the WPF/E forum someone was asking about how to dynamically load a XAML file. This post will explain how to accomplish this.
One of the great features of WPF/E is the fact that it is consistent with an established web architecture. At a high-level overview, within a webpage, a WPF/E component is hosted within an HTML element and you can use JavaScript to interact with the XAML content.
When working with XAML within the web architecture, it is important to remember both the Document Object Model (DOM) and the WPF/E Object Model.
Now let's get into the details of how to solve the problem of dynamically loading a XAML file. This really cool part is that we can do this in three easy steps.
- Reference the WPF/E control via the Document Object Model (DOM).
var wpfeControl = document.getElementById("wpfeControlID");
- Use the "Source" property of the WPF/E control to specify a XAML file.
wpfeControl.Source = "pathToXamlFile.xaml";
- Reload the content of the WPF/E control with the contents of XAML file referenced by the "Source" property.
wpfeControl.Reload();
Project Information | |
Source Code: | here |
Requirements: | WPF/E February 2007 CTP |
No comments:
Post a Comment