Click here to Skip to main content
15,891,372 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi every body,

I'm learning the silverlgith

Iam binding the data to datagrid inside datagrid.
but here i don't know how to make datagrid inside datagrid DataGridTemplateColumn.CellEditingTemplate
column
so if anyone konws let me know

Thanks in advance
Posted
Updated 10-May-12 2:49am
v3

1 solution

The attached sample has data class, UI XAML and code to test the grid inside the grid

C#
public class Product
    {
        public int ProductID { get; set; }
        public string Name { get; set; }
    }
    public class Category
    {
        public int CategoryID { get; set; }
        public string Name { get; set; }
        public List<Product> Products { get; set; }
    }


XAML:

HTML
<data:DataGrid x:Name="theGrid"
                       AutoGenerateColumns="True"
                       RowDetailsVisibility="VisibleWhenSelected"
                       HeadersVisibility="All"
                       >
            <data:DataGrid.RowDetailsTemplate>
                <DataTemplate>
                    <data:DataGrid Height="100" ItemsSource="{Binding Products}" AutoGenerateColumns="True" HeadersVisibility="Column"></data:DataGrid>
                </DataTemplate>
            </data:DataGrid.RowDetailsTemplate>
        </data:DataGrid>



Code to test:
C#
List<Category> Categories = new List<Category>();
for (int i = 1; i < 11; i++)
{
    Category cat = new Category { CategoryID = i, Name = "Category" + i };
    cat.Products = new List<Product>();
    for (int j = 1; j < 6; j++)
    {
        Product p = new Product { ProductID = (i * j), Name = "Product " + (i * j).ToString() };
        cat.Products.Add(p);
    }
    Categories.Add(cat);
}


theGrid.ItemsSource = Categories;
 
Share this answer
 
Comments
BO@007 17-May-12 2:53am    
hi ganesan
im already bind the data gird and inside datagrid.
but i didn't does the cellediting template with datagrid and inside datagrid.
so i want to know the cellediting template with datagrid and inside datagrid functionality.
ok na puriyuda(tamil word)...........

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900