Hi Guys,
I normally bind my datagrids through the following method:
C#:
smb1 = new DataTable(); smb1.Columns.Add("DESCRIPTION", typeof(string)); smb1.Columns.Add("DESCRIPTION_STATUS", typeof(string)); smb1.Columns.Add("DATE", typeof(DateTime)); smb1.Columns.Add("PERIOD", typeof(string)); smb1.Columns.Add("MACHINE", typeof(string)); smb1.Rows.Add("PRODUCT", result, DateTime.Now, "David", "SMB1"); smb1.Rows.Add("PRODUCT NUMBER", result2, DateTime.Now, "David", "SMB1"); smb1.Rows.Add("BATCH NUMBER", "Enebrel", DateTime.Now, "Sam", "SMB1"); SMB1.ItemsSource = smb1.DefaultView;
XAML:
<DataGrid Name="SMB1" ItemsSource="{Binding}" CanUserAddRows="False">
I would like to create a nested datagrid using the same type of C# code but with the data bound to a different datatable.
I think the XAMLS would be the same as below:
<DataGrid Name="SMB1" ItemsSource="{Binding}" AutoGenerateColumns="False" CanUserAddRows="False"><DataGrid.Columns><DataGridTemplateColumn Header="Datagrid" Width="*"><DataGridTemplateColumn.CellTemplate><DataTemplate ><DataGrid Name="data2" ItemsSource="{Binding}" CanUserAddRows="False" /></DataTemplate></DataGridTemplateColumn.CellTemplate></DataGridTemplateColumn></DataGrid.Columns></DataGrid>
but I cannot figure out how to bind to this second datagrid. I would like to use the same approach or one as close as possible to it. I don't think I can use the static approach as the data can be changed by the use of a datetimepicker once the application has been loaded up. Can anyone show me what my options are with a simple example please as I have spent the best part of a week studying this and have gone through most if not all the examples l could find on the internet but to no avail.
thanks Callum