Example E4031
Visible to All Users

WPF Data Grid - Display Detail Content in Tabs

This example creates tabbed details in the GridControl. The Orders tab displays the GridControl, and the Notes tab displays a memo field.

image

Files to Review

Documentation

More Examples

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

Example Code

WpfApplication18/MainWindow.xaml
XAML
<Window xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid" x:Class="WpfApplication18.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="450" Width="800"> <Window.Resources> <DataTemplate x:Key="EmployeeNotes"> <TextBlock Text="{Binding Path=Notes}" TextWrapping="Wrap" Padding="4"/> </DataTemplate> </Window.Resources> <Grid> <dxg:GridControl x:Name="grid" AutoGenerateColumns="AddNew"> <dxg:GridControl.View> <dxg:TableView DetailHeaderContent="Employees" AutoWidth="True" ShowGroupPanel="False"/> </dxg:GridControl.View> <dxg:GridControl.DetailDescriptor> <dxg:TabViewDetailDescriptor> <dxg:DataControlDetailDescriptor ItemsSourcePath="Orders"> <dxg:DataControlDetailDescriptor.DataControl> <dxg:GridControl AutoGenerateColumns="AddNew"> <dxg:GridControl.View> <dxg:TableView DetailHeaderContent="Orders" AutoWidth="True" ShowGroupPanel="False"/> </dxg:GridControl.View> </dxg:GridControl> </dxg:DataControlDetailDescriptor.DataControl> </dxg:DataControlDetailDescriptor> <dxg:ContentDetailDescriptor ContentTemplate="{StaticResource EmployeeNotes}" HeaderContent="Notes"/> </dxg:TabViewDetailDescriptor> </dxg:GridControl.DetailDescriptor> </dxg:GridControl> </Grid> </Window>
WpfApplication18/MainWindow.xaml.cs(vb)
C#
using DevExpress.Xpf.Grid; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Windows; namespace WpfApplication18 { public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); grid.ItemsSource = Employees.GetEmployees(); grid.Loaded += (d, e) => { (d as GridControl)?.ExpandMasterRow(0); }; } public class Employee { public string FirstName { get; set; } public string LastName { get; set; } public string Title { get; set; } public string Notes { get; set; } public List<Order> Orders { get; set; } } public class Order { public string Supplier { get; set; } public DateTime Date { get; set; } public string ProductName { get; set; } public int Quantity { get; set; } } public class Employees { public static ObservableCollection<Employee> GetEmployees() { ObservableCollection<Employee> employees = new ObservableCollection<Employee>() { new Employee() { FirstName="Bruce", LastName="Cambell", Title="Sales Manager", Notes="Education includes a BA in psychology from Colorado State University in 1970. He also completed 'The Art of the Cold Call.' Bruce is a member of Toastmasters International.", Orders = new List<Order>() }, new Employee() { FirstName="Cindy", LastName="Haneline", Title="Vice President of Sales", Notes="Cindy received her BTS commercial in 1974 and a Ph.D. in international marketing from the University of Dallas in 1981. She is fluent in French and Italian and reads German. She joined the company as a sales representative, was promoted to sales manager in January 1992 and to vice president of sales in March 1993. Cindy is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association.", Orders = new List<Order>() }, }; employees[0].Orders.Add(new Order() { Supplier = "Supplier 1", Date = DateTime.Now, ProductName = "TV", Quantity = 20 }); employees[0].Orders.Add(new Order() { Supplier = "Supplier 2", Date = DateTime.Now.AddDays(3), ProductName = "Projector", Quantity = 15 }); employees[0].Orders.Add(new Order() { Supplier = "Supplier 3", Date = DateTime.Now.AddDays(3), ProductName = "HDMI Cable", Quantity = 50 }); employees[1].Orders.Add(new Order() { Supplier = "Supplier 1", Date = DateTime.Now.AddDays(1), ProductName = "Blu-Ray Player", Quantity = 10 }); employees[1].Orders.Add(new Order() { Supplier = "Supplier 2", Date = DateTime.Now.AddDays(1), ProductName = "HDMI Cable", Quantity = 10 }); employees[1].Orders.Add(new Order() { Supplier = "Supplier 3", Date = DateTime.Now.AddDays(1), ProductName = "Projector", Quantity = 10 }); employees[1].Orders.Add(new Order() { Supplier = "Supplier 4", Date = DateTime.Now.AddDays(1), ProductName = "Amplifier", Quantity = 10 }); return employees; } } } }

Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.