I'd like to have a reusable window in my desktop application that could potentially have different xamls "injected" into it. Because I'd like all my windows to have the same look (I have a nifty title bar and close button, etc)
For example, I'd like to have a messagebox (ok/cancel/string) used in it. I'd like it to be used to host a form, etc.
I currently have:
MyWindow.xaml/cs (is a Window)
MyMessageBox.xaml/cs (is a User Control)
MyForm.xaml/cs (is a User Control)
So what is the best way to implement this. Do I just put a ContentPresenter in MyWindow and then somehow "inject" the other xamls into it? Do I need the other controls to inherit something from the base window?
I'm just looking for some feedback on the best way to go about what I'm trying to do. Thanks
A simple approach would be a Window with a Frame, and then load pages into that Frame on demand.
I agree with with Henk Holterman's answer. I've just written a small 'framework' for WPF applications of this sort. I use an inteface on the 'content' pages to define common functionality for the code-behind; I have a generic page template that I use to give me a caption block, close button, etc.
I'd avoid visual inheritance with WPF unless you absolutely need it - it can be rather tricky to get right.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With