views:

444

answers:

1

I'm rebuilding a WPF slide-show application structure that I found in the downloadable code for this WPF video.

There is a Presentation class which has an INotifyPropertyChanged property "CurrentSlide" which changes as you click next/previous buttons and is displayed dynamically in a Frame element.

The downloaded code loads Pages into this frame, but I experimented with loading UserControls which seem to work just as well, in fact I can't find any difference.

Does anyone know of any differences in loading Pages or UserControls into a XAML Frame element?

<Window x:Class="TestFull8229.Views.MainView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:c="clr-namespace:TestFull8229.Commands"
    xmlns:viewModels="clr-namespace:TestFull8229.ViewModels"
    Title="Main Window" Height="400" Width="800">

    <Window.Resources>
        <viewModels:Presentation x:Key="presentation"/>
    </Window.Resources>

    <DockPanel>
        <StackPanel>
            <Viewbox Stretch="Uniform">
                <Frame Width="800" Height="600" 
                       Source="{Binding Path=CurrentSlide, 
                       Source={StaticResource presentation}}"/>
            </Viewbox>
        </StackPanel>
    </DockPanel>
</Window>
+2  A: 

A Page is designed to be in a navigation container so it has a title property and access to the navigation service. But as you noted, a UserControl could be loaded in a frame as well as could any valid WPF "content". Page also serves as a base class for a PageFunction which is useful for creating structured navigation such as wizards.

Oh and one more thing... a Page can be loaded in Internet Explorer without a host application. In other words, IE can act as a navigation container for the page just like Frame or NavigationWindow.

Josh Einstein
yes, I've found in the code that the main .xaml file reads out the Title property of the loaded page, which a UserControl doesn't have, so that is one reason to use Pages at least in this example
Edward Tanguay