Question

First I have to make clear what i am Trying to accomplish, it's going to be an app where I have 4 Panoramas, the first Page on every Panorama is different. But the last 3 Pages are identical.

Is it anyhow possible not to define these 3 Pages in every Panorama? Can I define the Content in an XAML File and load it into the Panoramas? So if i have changes i dont have to make them on 4 different Pages...

I hope you understood my question.

Thank you.

Was it helpful?

Solution

Probably the simplest way is to put the contents of each of the identical pages into UserControls, and reference the UserControls in the panorama items.

EDIT: Example

Current situation:

<controls:Panorama Title="my application">
    <controls:PanoramaItem Header="first item">
        <!-- Your Panorama Item Content -->
    </controls:PanoramaItem>
    <controls:PanoramaItem Header="second item">
        <!--  Item Content To Be Moved -->
        <TextBlock Text="ToBeMovedToUserControl"/>  
    </controls:PanoramaItem>
</controls:Panorama>

Now put the contents of the repeating panorama items in a UserControl: Add a new UserControl in Visual Studio (select "UserControl" from the item templates), and add the XAML that you currently have in the PanoraItem:

<UserControl x:Class="PanoramaApp1.WindowsPhoneControl1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    d:DesignHeight="480" d:DesignWidth="480">

    <Grid x:Name="LayoutRoot">
         <TextBlock Text="ToBeMovedToUserControl"/>  
    </Grid>
</UserControl>

and change the panorama XAML to:

<controls:Panorama Title="my application">
    <controls:PanoramaItem Header="first item">
        <!-- Your Panorama Item Content -->
    </controls:PanoramaItem>
    <controls:PanoramaItem Header="second item">
        <!--  Item Content To Be Moved -->
        <WindowsPhoneControl1/>
    </controls:PanoramaItem>
</controls:Panorama>

Note that you may have to inlcude a namespace definition in the page containing the panorama so that the control can be found.

OTHER TIPS

add the panoramaitem dynamically in the .cs

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top