How to create a Frame in WPF?

The Frame control in WPF supports content navigation within content. A Frame can be hosted within a Window, NavigationWindow, Page, UserControl, or a FlowDocument control.

This XAML code shows how to create a Frame control and sets its Source property to load a XAML page within it.

<Window x:Class="FrameSample.Window1"



    Title="Window1" Height="300" Width="300">


        <TextBlock>Outside area of frame</TextBlock>

        <Frame Source="Page1.xaml">           





The Window looks like this. The purple area is the Page1.xaml and white area is outside of the Frame.


Now you can manage contents of a frame the way you want.

For example, the following code rotates the contents of frame to 45 angle.

<Frame Source="Page1.xaml">


        <RotateTransform Angle="45" />



The new output looks like this.