This question is locked. New answers and comments are not allowed.
Hi All,
I try to bind a grid column to a specific item of an collection and used this item into my Cell Template.
Here is the item source of the grid:
Here is the ProducedAndPlannedGridData Class
Each item of ProducedAndPlannedGridData contain the same number of CumulProdData.
Here is the way i create and bind the colum
And here is the CellTemplate i used:
But the binding into the cellTemplate does not work.
Could you help me with this?
Thanks,
Mathieu
I try to bind a grid column to a specific item of an collection and used this item into my Cell Template.
Here is the item source of the grid:
mProducedAndPlannedGridData = New ObservableCollection(Of ProducedAndPlannedGridData) grdData.ItemsSource = mProducedAndPlannedGridDataHere is the ProducedAndPlannedGridData Class
Public Class ProducedAndPlannedGridData Private mProduct As String Private mDynCol As ObservableCollection(Of CumulProdData) Public Property Product() As String Get Return mProduct End Get Set(ByVal value As String) mProduct = value End Set End Property Public Property DynCol() As ObservableCollection(Of CumulProdData) Get Return mDynCol End Get Set(ByVal value As ObservableCollection(Of CumulProdData)) mDynCol = value End Set End PropertyEnd ClassPublic Class CumulProdData Private mProduced As Double Private mPlanned As Double Public Property Produced() As Double Get Return mProduced End Get Set(ByVal value As Double) mProduced = value End Set End Property Public Property Planned() As Double Get Return mPlanned End Get Set(ByVal value As Double) mPlanned = value End Set End PropertyEnd ClassEach item of ProducedAndPlannedGridData contain the same number of CumulProdData.
Here is the way i create and bind the colum
AddColumnHeaders("Product", "Product", True, grdData) Dim int As Integer = 0 If Not mProducedAndPlannedGridData Is Nothing Then For Each col In mProducedAndPlannedGridData(0).DynCol AddColumnHeaders("DynCol[" + int.ToString + "]", col.ColName, True, grdData, , TryCast(Me.Resources("CellPlannedAndRealProductionTemplate"), DataTemplate), True) int += 1 Next End IfPrivate Sub AddColumnHeaders(ByVal strUniqueName As String, _ ByVal strColumnName As String, _ ByVal blnVisible As Boolean, _ ByVal grdIn As RadGridView, _ Optional ByVal strDataFormatString As String = "", _ Optional ByVal CellEditTemplate As DataTemplate = Nothing, _ Optional ByVal blnIsReadOnly As Boolean = True) Dim Column As New GridViewDataColumn Column.UniqueName = strUniqueName Column.Header = strColumnName Column.IsVisible = blnVisible Column.IsReadOnly = blnIsReadOnly If strDataFormatString <> "" Then Column.DataFormatString = strDataFormatString End If If Not CellEditTemplate Is Nothing Then Column.DataMemberBinding = New Binding(strUniqueName) Column.CellTemplate = CellEditTemplate End If grdIn.Columns.Add(Column)End SubAnd here is the CellTemplate i used:
<DataTemplate x:Name="CellPlannedAndRealProductionTemplate"> <StackPanel VerticalAlignment="Top" Orientation="Vertical"> <TextBlock x:Name="txtProduced" Text="{Binding Produced}"/> <TextBlock x:Name="txtPlanned" Text="{Binding Planned}"/> </StackPanel></DataTemplate>But the binding into the cellTemplate does not work.
Could you help me with this?
Thanks,
Mathieu