WPF: How to implement a common window?

I would like to have a reusable window in my desktop application that could potentially have different xamls attachments. Because I would like all my windows to have the same look (I have a great title bar and close button, etc.)

For example, I would like to have a message in it (ok / cancel / string). I would like it to be used to host a form, etc.

Currently I have:
MyWindow.xaml / cs (this is a window)
MyMessageBox.xaml / cs (this is a user control)
MyForm.xaml / cs (this is a user control)

So what is the best way to implement this. Did I just put ContentPresenter in MyWindow, and then somehow “inject” other xamls into it? Do I need other controls to inherit from the base window?

I'm just looking for feedback on the best way to do what I'm trying to do. Thanks

+3
source share
6 answers

As a result, I got some tips and tricks from this article:

http://www.codeproject.com/KB/WPF/CustomFrames.aspx

this is exactly what i was looking for!

0
source

A simple approach would be a window with a frame, and then loading pages into this frame on demand.

+2
source

. "" WPF . inteface "" ; , , , ..

WPF, - .

+1

DataWindow of Catel . :

DataWindow.cs

0

You should seriously consider using Prism (developed by Microsoft, emerging from Patterns and Practice ) for this; it was built to handle just these scenarios, providing tools for building user interfaces .

0
source

Source: https://habr.com/ru/post/1791288/


All Articles