mahes
mahes

Reputation: 1152

Create new WPF page which is subset of current page

I am creating a WPF application which behaves like a 'Windows Wizard', when I press a button in MainWindow it should navigate to say Page2.

For Page2 I added a new WPF page from VisualStudio.
Is there any way for this new page to inherit some attributes from main window, like background,dimension,title,etc since most of the attributes are same.

Upvotes: 0

Views: 81

Answers (1)

Mark
Mark

Reputation: 3283

you can use ResourceDictionaries for stuff like Color Attributes etc.

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Color x:Key="LimeColor">#FFA4C400</Color>
    <SolidColorBrush Color="{StaticResource LimeColor}" x:Key="Lime" />
</ResourceDictionary>

App.xaml

<Application.Resources>
    <ResourceDictionary Source="pack://application:,,,/YourDictionary.xaml" /> 
</Application.Resources>

For the correct Source see: Pack URIs in WPF

Page and Window for example:

<Grid Background="{StaticResource Lime}">

Or you can define Styles and Templates in WPF for any ControlTypes.

For further information : Control Customization on MSDN

Upvotes: 2

Related Questions