This question is locked. New answers and comments are not allowed.
I'm revising my grids to not use PreviewDataRecordCreate with the Q3 release and I'm following the Custom Hierarchy example. Everything works great except I cannot determine how to dynamically add a button to a column in my DataLoading event.
This is the XAML of what I'm trying to reproduce in code.
This is the XAML of what I'm trying to reproduce in code.
| <telerikGridView:GridViewDataColumn Width="50" > |
| <telerikGridView:GridViewDataColumn.CellStyle> |
| <Style TargetType="Telerik_Windows_Controls_GridView:GridViewCell"> |
| <Setter Property="Template"> |
| <Setter.Value> |
| <ControlTemplate TargetType="Telerik_Windows_Controls_GridView:GridViewCell"> |
| <Button Click="ReportSelectCommand" |
| HorizontalAlignment="Center" Content="Resume" ToolTipService.ToolTip="Continue saved report" |
| VerticalAlignment="Center" DataContext="{Binding id}"> |
| </Button> |
| </ControlTemplate> |
| </Setter.Value> |
| </Setter> |
| </Style> |
| </telerikGridView:GridViewDataColumn.CellStyle> |
| </telerikGridView:GridViewDataColumn> |
My DataLoading event - I cannot determine how to add the button control to the first datacolumn.
| private void grdReports_DataLoading(object sender, GridViewDataLoadingEventArgs e) |
| { |
| GridViewDataControl dataControl = (GridViewDataControl)sender; |
| if (dataControl.ParentRow != null) |
| { |
| dataControl.CanUserFreezeColumns = false; |
| dataControl.ShowGroupPanel = false; |
| dataControl.AutoGenerateColumns = false; |
| dataControl.ColumnsWidthMode = ColumnsWidthMode.Fill; |
| // THIS IS AS FAR AS I GOT. NOT SURE HOW TO ADD A CONTROL TO A CELL |
| GridViewDataColumn column = new GridViewDataColumn(); |
| column.CellStyle.TargetType = typeof(Telerik.Windows.Controls.GridView.GridViewCell); |
| /////////////////////////////////////////////////////////////////////// |
| column = new GridViewDataColumn(); |
| column.Header = "Title"; |
| column.DataMemberBinding = new System.Windows.Data.Binding("assocname"); |
| dataControl.Columns.Add(column); |
| column = new GridViewDataColumn(); |
| column.Header = "Date Created"; |
| column.DataMemberBinding = new System.Windows.Data.Binding("createDate"); |
| dataControl.Columns.Add(column); |
| column = new GridViewDataColumn(); |
| column.Header = "Current Page"; |
| column.DataFormatString = "{0:c}"; |
| column.DataMemberBinding = new System.Windows.Data.Binding("CurrentPage"); |
| dataControl.Columns.Add(column); |
| column = new GridViewDataColumn(); |
| column.Header = "Components"; |
| column.DataMemberBinding = new System.Windows.Data.Binding("compCount"); |
| dataControl.Columns.Add(column); |
| } |
| } |
Thank you.
