We are migrating to Winforms to WPF based solution. We have custom XML definition which are used to build the windows form at runtime.
Since XAML is XML based, can we define a HelloWorldWindow.xml file with XAML definition and can it be loaded into the WPF app without any code behind CSharp files? We will attach the code behind hook at runtime.
How to attach the code behind at runtime?
I have done loading XAML at runtime, here is a short example
Create an XML file Tempwin.xml using this XAML
Create a sample WPF Application with the below xaml
Paste the below C# code in codebehind the Button_Click
if you want to load xaml at runtime you cannot give any code behind your XAML file. So i have removed the x:Class attribute before creating the xml
Events Hooking....
You can display Xaml dynamically like this:
See the XamlReader class for further information: http://msdn.microsoft.com/en-us/library/ms613427%28v=VS.95%29.aspx