Creating a table-like user interface
Table layout is a popular placement strategy, supported by the Grid
panel. Let's examine the Grid
and see what it's capable of.
Getting ready
Make sure Visual Studio is up and running.
How to do it...
We'll create a simple UI that benefits from a grid-like layout and demonstrate some of its features:
- Create a new WPF application named
CH03.GridDemo
. - Open
MainWindow.xaml
. There's already aGrid
placed inside theWindow
. That's because theGrid
is typically used as the main layout panel within a window. - Change the
Title
ofWindow
toGrid Demo
. - Inside the
Grid
, add the following markup to create some rows and columns:<Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition ...
Get Windows Presentation Foundation 4.5 Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.