Creating a master-detail view
A master-detail view is a common way to display lots of information. The master shows a compressed view of some objects, while the detail view shows the selected object (from the master) in greater detail, as appropriate. Let's examine a typical way to achieve this in WPF.
Getting ready
Make sure Visual Studio is up and running.
How to do it...
We'll create an application that shows a list of processes and a detailed look of a selected process.
Create a new WPF application named
CH06.MasterDetail
.Open
MainWindow.xaml
. Add the following markup to the existingGrid
, creating two columns with first holding aListBox
:<Grid.ColumnDefinitions> <ColumnDefinition Width="200"/> <ColumnDefinition /> </Grid.ColumnDefinitions> <ListBox ItemsSource="{Binding}" FontSize="16" DisplayMemberPath="ProcessName" x:Name="_master"/>
The
ListBox
will serve as the master view, showing a flat list of all running processes on the system. Now...