--- title: "How to create a complex Grid" description: "An example on how to use a Grid control to create a layout that looks like a monthly calendar." ms.date: "03/30/2017" helpviewer_keywords: - "calendar [WPF], creating" - "monthly calendar [WPF], creating" - "Grid control [WPF], creating [WPF], complex grid" ms.assetid: 4ce3040a-a156-4364-9596-98ca1eca5550 --- # How to create a complex Grid This example shows how to use a control to create a layout that looks like a monthly calendar. ## Example The following example defines eight rows and eight columns by using the and classes. It uses the and attached properties, together with elements, which fill the backgrounds of various columns and rows. This design is possible because more than one element can exist in each cell in a , a principle difference between and . The example uses vertical gradients to the columns and rows to improve the visual presentation and readability of the calendar. Styled elements represent the dates and days of the week. elements are absolutely positioned within their cells by using the property and alignment properties that are defined within the style for the application. [!code-xaml[GridComplex#1](~/samples/snippets/csharp/VS_Snippets_Wpf/GridComplex/CS/default.xaml#1)] The following image shows the resulting control, a customizable calendar: ![Screenshot of the resulting control](././media/how-to-create-a-complex-grid/wpf-manual-calendar.png) ## See also - - - [Painting with Solid Colors and Gradients Overview](../graphics-multimedia/painting-with-solid-colors-and-gradients-overview.md) - [Panels Overview](panels-overview.md) - [Table Overview](../advanced/table-overview.md)