Creating a tabbed layout
To accommodate more content in a window layout, tabbed user interfaces are mostly used. They allow users to open multiple pages in a single window. For example, most of the recent internet browsers use tabbed interface to let the user open multiple web pages simultaneously in a single window.
WPF provides TabControl
to create the tabbed layout. In this recipe, we will learn the basics of tab interfaces, with a simple example to let you understand how it works.
Getting ready
To get started, make sure that you have opened Visual Studio IDE. Now create a new project named CH03.TabControlDemo
, based on the available WPF application project template.
How to do it...
Let's create the UI interface to host a very basic tab control with a few tab items inside it. Perform the following steps:
- From the
Solution Explorer
window, open theMainWindow.xaml
file. - Inside the default
Grid
panel, add theTabControl
with twoTabItem
controls as shown in the following code:
<Grid> ...