In this article, I will represent the frame object witch is a container control that enables to navigate through internet and display some contents such as an Html page. Normally, it is hosted within other elements such a Grid controls, tab Controls and so forth.

The sequence of events that are raised when a navigation action is performed are represented in the following diagram

Figure 1

Now, I will represent some of the frame most important members

Member

Description

Source-property

It represents the current URI used to navigate, it is necessary to create a new URI object and overload its constructor by the URI string:oFrame = newFrame();oFrame.Source= newUri( @"http://www.tunisianproducts.com/", UriKind.RelativeOrAbsolute);

CurrentSource-property

This property gets the current used source, indeed this property couldn't be used directly using XAML. It is only used within a C# code context

Content-property

This property enables get or set a contained object

Navigate-method

It has three overloaded instances, the first one is Navigate(object) it enables Navigate asynchronously to content that is contained by an object, the second one is Navigate(uri) it Navigates asynchronously to content that is specified by a uniform resource identifier. Then the third is Navigate(object,object) it enables Navigate asynchronously to content that is contained by an object, and passes an object that contains data to be used for processing during navigation. Finally the Navigate(uri, object) that enables Navigate asynchronously to source content located at a uniform resource identifier (URI), and passes an object that contains data to be used for processing during navigation.

GoForward-method

It enables go to the most recent item located in the forward navigation history

GoBack-method

It enables go to the most recent item located in the previous navigation history

NavigationUIVisibility-property

As the frame provides a user interface that enables navigate forward and back. This user interface could be displayed or not according to this property state. To render this user interface visible then oFrame.NavigationUIVisibility = System.Windows.NavigationUIVisibility.Visible;

JournalOwnership-property

This is very important property witch determines if the frame will manage its own navigation history or it will be leaved to the parent navigator such as a Navigation Window object. To enable the frame manage its navigation history then oFrame.JournalOwnership = System.Windows.Navigation.JournalOwnership.OwnsJournal;else if the parent is preferred to do this then oFrame.JournalOwnership = System.Windows.Navigation.JournalOwnership.UsesParentJournal;Else, the Automatic alternative is used to indicate that the journal ownership depends on the type of parent.oFrame.JournalOwnership = System.Windows.Navigation.JournalOwnership.Automatic;

Those are the most important properties according to the frame object.

To more understand the frame object in practice, I provide this example that consists of creating a primitive browser witch is developed by following those steps.

System.Windows.MessageBox.Show("You have to define an uri", "You have to define an uri");

}

}

privatevoid oTabItem_MouseDown(object sender, MouseEventArgs e)

{

//This enble to discard a tab item by just right click on it

tabControl1.Items.Remove(tabControl1.SelectedItem);

}

privatevoid OpenFile_Click(object sender, RoutedEventArgs e)

{

//This enables to open a html file in the local machine

System.Windows.Forms.OpenFileDialog Open = new System.Windows.Forms.OpenFileDialog();

Open.Filter = "(*.html)|*.html";

Open.ShowDialog();

if (Open.ShowDialog() == System.Windows.Forms.DialogResult.OK)

oFrame.Source = new Uri(Open.FileName);

}

privatevoid Quit_Click(object sender, RoutedEventArgs e)

{

//This enables to close the current window

this.Close();

}

//This button is used to directly browse to the desired internet content

privatevoid button1_Click(object sender, RoutedEventArgs e)

{

NewTab_Click(sender, e);

}

}

}

Now, run the application and the result will be

Finally, I can say that it is a very primary browser. It is constructed thanks to the frame object, so try to play around with it. Indeed, it could be enhanced to perform other functionalities supported browsers such as internet explorer or Opera for example. That's it

The author holds a master degree in NTIC specialized in software developement delivered by the high school of communication SUPCOM, he also holds a bachelor degree in finance delivered by the economic s... Read more