WP8 how to create a base page and use it

I searched googled but didn't get any useful resources, so I decided to ask.

Problem:

I have a Windows Phone 8 C # / XAML.NET 4.5 application that will have several pages (15 - 50) that will look similar + the same data file for one ViewModel instance :

    --------------------------
    |logo         usermenu(v)|
    --------------------------
    |                        |
    |                        |
    |                        |
    |     ..variable..       |
    |     ..content...       |
    |                        |
    |                        |
    --------------------------

Question:

I can not find anything useful in this matter, can someone explain how to do this?

(I am new - this means that I am grateful for any useful information, but much more for explaining the mannequins)

  • How to create a base page / ancestor to display my pages?

  • Is there a way to set the datacontext on the ancestor?

  • How to use this base page / ancestor?

PS: , , ,

+4
2

, , , .

, 15-50 , DataContext. , , . , , , .

:

  • - , , . , cs xaml.

  • , datacontext , , . DataContext .

  • - :

( )

namespace SO19398590
{
    using Microsoft.Phone.Controls;

    public class MyBasePage : PhoneApplicationPage
    {
    }
}

, .
CS:

public partial class MainPage : MyBasePage
{
    public MainPage()
    {
        InitializeComponent();
    }
}

xaml (partial):

<so19398590:MyBasePage
    x:Class="SO19398590.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:so19398590="clr-namespace:SO19398590"
    SupportedOrientations="Portrait">

    <Grid x:Name="LayoutRoot" Background="Transparent">
        <!-- put stuff here -->
   </Grid>

</so19398590:MyBasePage>

, , , .
, Windows Phone , . () , , .

[ ] , , .
, - , PhoneApplicationFrame .

, , "" , , " ".

+6

, - UserControl, . UserControl .

+2

All Articles