WPFでは、マスターページの使用をサポートしていません。 ASP.Netはもともと、WPFアプリケーションを作成する方法のように、マスターページのようなより多様なオプションを使用して、Webアプリケーションを作成するための簡単な方法として作成されました。
ただし、カスタムコントロールの助けを借りてWPFでこれを実現するいくつかのベストプラクティスがあります。
たとえば、タイトルアブストラクトとコンテンツを含むカスタムコントロール。
namespace MasterPages.Master
{
public class Master : Control
{
static Master()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(Master),
new FrameworkPropertyMetadata(typeof(Master)));
}
public object Title
{
get { return (object)GetValue(TitleProperty); }
set { SetValue(TitleProperty, value); }
}
public static readonly DependencyProperty TitleProperty =
DependencyProperty.Register("Title", typeof(object),
typeof(Master), new UIPropertyMetadata());
public object Abstract
{
get { return (object)GetValue(AbstractProperty); }
set { SetValue(AbstractProperty, value); }
}
public static readonly DependencyProperty AbstractProperty =
DependencyProperty.Register("Abstract", typeof(object),
typeof(Master), new UIPropertyMetadata());
public object Content
{
get { return (object)GetValue(ContentProperty); }
set { SetValue(ContentProperty, value); }
}
public static readonly DependencyProperty ContentProperty =
DependencyProperty.Register("Content", typeof(object),
typeof(Master), new UIPropertyMetadata());
}
}
フル例はである:
https://www.codeproject.com/Articles/23069/WPF-Master-Pages
通常は、固定デザインのウィンドウが1つしかなく、内部のコンポーネントを入れ替えて見ているものを変更します。マスターページは、レイアウト全体を再構築する必要がある場所に移動していないため、実際にWPFには意味をなさない。 – poke
MVVMは... ContentControl/ItemsControl + data templatesを行います。 – Sinatr