I need to put a stackpanel inside the table cell but if i did my logic like this....
DataGrid dg = new DataGrid();
StackPanel sp = new StackPanel();
sp.Height = 18;
sp.Width = 60;
sp.Orientation = Orientation.Horizontal;
Button btn = new Button();
btn.Width = 10;
btn.Height = 10;
sp.Children.Add(btn);
Label bt = new Label();
bt.Content = "test";
bt.Margin = new Thickness(0, -3, 0, 0);
sp.Children.Add(bt);
DataTable dt = new DataTable();
DataColumn dc = new DataColumn("hello");
dt.Columns.Add(dc);
DataRow dr = dt.NewRow();
dr[0] = sp; dt.Rows.Add(dr);
dg.ItemsSource = dt.DefaultView;
l1.Content = dg;
it is showing "System.Windows.Controls.StackPanel" in the cell..... how to get a StackPanel(with multiple C开发者_开发技巧ontrols) in side the GridView cell
You should create custom template for your grid cells. See this.
精彩评论