articles

Home / DeveloperSection / Articles / Frame control in WPF

Frame control in WPF

Frame control in WPF

Anonymous User 56195 09-Apr-2011

Frame control in WPF

In WPF we can use Frame control to display the content of another window with the same window.
WPF frame control does not support displaying HTML content.
We can navigate to another form and show the content of that form within the same window.
The frame control in WPF supports navigation within the content.
A-frame can be hosted within a window, navigation window or user control, etc.
In XAML <Frame /> element is used to create a frame control.
In this demonstration, I will show you how to use frame control in WPF.

Following XAML code snippet represent frame control in WPF
<Frame x:Name="frame1" Width="200" Height="200" Background="LightPink" Canvas.Left="97" Canvas.Top="28">
            <Frame.BitmapEffect>
                <DropShadowBitmapEffect />
            </Frame.BitmapEffect>
           
</Frame>
Output of the following code snippet is as follows

Frame control in WPF

Rotating Frame by an angle

We can rotate frame providing an angle to frame object.

The following XAML code snippet represents are used to rotate a frame
<Frame x:Name="frame1" Width="200" Height="200" Background="LightPink" Canvas.Left="97" Canvas.Top="28">
            <Frame.BitmapEffect>
                <DropShadowBitmapEffect />
            </Frame.BitmapEffect>
            <Frame.LayoutTransform>
                <RotateTransform Angle="40" />
            </Frame.LayoutTransform>
</Frame>
The output of the following code snippet is as follows

Frame control in WPF

Navigating content in the Frame control

XAML code which to create User Interface of the navigation frame

<Canvas>
        <Frame x:Name="frame1" Width="479" Height="250" Background="LightPink" Canvas.Left="12" Canvas.Top="12">
            <Frame.BitmapEffect>
                <DropShadowBitmapEffect />
            </Frame.BitmapEffect>
        </Frame>
        <Button Canvas.Left="116" Canvas.Top="276" Content="Show Content" Height="23" x:Name="btnContent" Width="253" Click="btnContent_Click" />
</Canvas>
The output of the following code snippet is as follows

Frame control in WPF

On the click event of the Show Content button write the following code
private void btnContent_Click(object sender,  RoutedEventArgs e)
{
            frame1.Navigate(new Uri("http://www.google.com"));
}
The output of the following code

Frame control in WPF


You should also read this Article - Group Name Field in Crystal Report

 


wpf wpf 
Updated 12-Apr-2020
I am a content writter !

Leave Comment

Comments

Liked By