Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between loading Pages or UserControls into a XAML Frame Element?

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>
like image 512
Edward Tanguay Avatar asked May 18 '09 09:05

Edward Tanguay


1 Answers

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.

like image 199
Josh Avatar answered Oct 23 '22 17:10

Josh