I have created a WPF app where I dynamicly build XAML elements using c# code and then add them to a root "container" grid.
What I'm trying to do is take advantage of the features in Blend and create some XAML Pages that have their own set of code behind logic, Storyboards, etc.
I want to load that XAML at runtime, however for some reason my approach is not working and I'm at a loss for why.
This what what I did before. In my root Window I create a new MyModule and add it to my contentRoot.
myModule = new MyModule();
contentRoot.Children.Add(myModule );
(Approach that works) MyModule class extends Canvas and consists of a .XAML file and .CS code behind file. The XAML is just a root canvas, and the .CS has all the logic to create elements and add them to the root canvas.
When I use this same approach where MyModule is now extends Page nothing shows up. The XAML now has a lot of content in it including a Canvas.Resources Canvas.Triggers, and a bunch of other elements.
How can I load pre-created XAML content from a Class including the code behind logic at run time?