sachin kulkarni
sachin kulkarni

Reputation: 2828

Xaml file in other Xaml file

I am basically new to WPF.I have 2 Xaml files.

WpfCurrentSessionViewer.xaml and MainWindow.xaml. Say WpfCurrentSessionViewer acts as a control which has labels in it. MainWindow is the xaml where we need to inscribe the control.

Say in Asp.Net applications , we have an aspx page and a master page. In similar way I need to do that as WpfCurrentSessionViewer.xaml acts as a master page and MainWindow.xaml acts as an aspx page .

Regards,

Sachin K

Upvotes: 0

Views: 220

Answers (3)

GameAlchemist
GameAlchemist

Reputation: 19294

Are you talking about frames ? There's a very good article about using frames here : http://www.paulstovell.com/wpf-navigation

Upvotes: 0

Dan Puzey
Dan Puzey

Reputation: 34200

I think your question contradicts itself in terms of which way around the two controls are:

Say WpfCurrentSessionViewer acts as a control which has labels in it. MainWindow is the xaml where we need to inscribe the control.

WpfCurrentSessionViewer.xaml acts as a master page and MainWindow.xaml acts as an aspx page.

Either way, it sounds like you need to have one Window and one UserControl (or CustomControl, but if you're new to WPF you'll find a UserControl easier).

Upvotes: 1

devdigital
devdigital

Reputation: 34349

What you are talking about is UI composition, or view composition. This is usually achieved in WPF with a ContentControl which has a Content property which you can set to any type, in your case, an instance of your MainWindow type.

I would consider adopting the MVVM design pattern when building WPF applications, and using an MVVM framework such as Caliburn.Micro, which makes view composition very straightforward.

Upvotes: 0

Related Questions