Hi,
My application is in MVVM. I have a RadGridview where 2 columns are Databound and I have to generate third column dynamically with RowNumbers.
Here is my code. I am getting (collection) in the third column. The other 2 columns are fine. Please help me on this.
XAML:
<telerik:RadGridView Name="TestGridView" ItemsSource="{Binding TestListView}" AutoGenerateColumns="False">
<telerik:RadGridView.Columns>
<telerik:GridViewColumn Header="RowCount">
<telerik:GridViewColumn.CellTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding TestRowNumber}" />
</StackPanel>
</DataTemplate>
</telerik:GridViewColumn.CellTemplate>
</telerik:GridViewColumn>
<telerik:GridViewDataColumn DataMemberBinding="{Binding FirstName}" Header="NetBIOS Name" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding Salary}" Header="Model" />
</telerik:RadGridView.Columns>
</telerik:RadGridView>
ViewModel:
public void Testupdate()
{
RadObservableCollection<int> rno = new RadObservableCollection<int>();
for (int i = 1; i <= TestList.Count; i++)
{
rno.Add(i);
}
TestRowNumber= rno;
}
private RadObservableCollection<int> _testRowNumber;
public RadObservableCollection<int> TestRowNumber
{
get { return _testRowNumber; }
set
{
_testRowNumber = value;
OnPropertyChanged();
}
}
Its showing correct count in the rno with items 1 to 6. But when displaying on the grid, its showing (collection). I am not able to trace where I am going wrong. Please correct me.
Thank you.
My application is in MVVM. I have a RadGridview where 2 columns are Databound and I have to generate third column dynamically with RowNumbers.
Here is my code. I am getting (collection) in the third column. The other 2 columns are fine. Please help me on this.
XAML:
<telerik:RadGridView Name="TestGridView" ItemsSource="{Binding TestListView}" AutoGenerateColumns="False">
<telerik:RadGridView.Columns>
<telerik:GridViewColumn Header="RowCount">
<telerik:GridViewColumn.CellTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding TestRowNumber}" />
</StackPanel>
</DataTemplate>
</telerik:GridViewColumn.CellTemplate>
</telerik:GridViewColumn>
<telerik:GridViewDataColumn DataMemberBinding="{Binding FirstName}" Header="NetBIOS Name" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding Salary}" Header="Model" />
</telerik:RadGridView.Columns>
</telerik:RadGridView>
ViewModel:
public void Testupdate()
{
RadObservableCollection<int> rno = new RadObservableCollection<int>();
for (int i = 1; i <= TestList.Count; i++)
{
rno.Add(i);
}
TestRowNumber= rno;
}
private RadObservableCollection<int> _testRowNumber;
public RadObservableCollection<int> TestRowNumber
{
get { return _testRowNumber; }
set
{
_testRowNumber = value;
OnPropertyChanged();
}
}
Its showing correct count in the rno with items 1 to 6. But when displaying on the grid, its showing (collection). I am not able to trace where I am going wrong. Please correct me.
Thank you.