This question is locked. New answers and comments are not allowed.
Hello,
I've created an Untyped collection ou array of items to assign to a RadGridView. Everything works well on ReadOnly mode! If I set ReadOnly to false and double click the cell, an exception ("Object reference not set to an instance of an object ") if thrown on method GridViewCell.ShowEditor().
If I use System.Windows.Controls.Data.DataGrid it works fine! If I create a typed collection or list and assign to the grid it works fine!
It seams that RadGridView could not assign a CellEditor (at least a default/generic one) when there's no type defined on Collections!
Here is my code:
<UserControl x:Class="SilverlightApplication23.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"
xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
Width="400" Height="300">
<Grid x:Name="LayoutRoot" Background="White">
<StackPanel>
<telerik:RadGridView IsReadOnly="False" x:Name="dgEntityTypes" AutoGenerateColumns="False">
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn HeaderText="Name" DataMemberBinding="{Binding Name}" />
</telerik:RadGridView.Columns>
</telerik:RadGridView>
<data:DataGrid x:Name="dgEntityTypes2" BorderBrush="Transparent" AutoGenerateColumns="False" IsReadOnly="False" CanUserResizeColumns="False">
<data:DataGrid.Columns>
<data:DataGridTextColumn Header="Name" Binding="{Binding Path=Name}"/>
</data:DataGrid.Columns>
</data:DataGrid>
</StackPanel>
</Grid>
</UserControl>
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
ObservableCollection<Object> mycol = new ObservableCollection<Object>();
Test t1 = new Test();
t1.Name = "aaa";
t1.Id = "111";
Test t2 = new Test();
t2.Name = "aaa";
t2.Id = "111";
mycol.Add(t1);
mycol.Add(t2);
dgEntityTypes.ItemsSource = mycol;
dgEntityTypes2.ItemsSource = mycol;
}
}
public class Test
{
public string Name { set; get; }
public string Id { set; get; }
}
Is there any work-arround for this issue? This is a problem with a huge impact on our application because it's used a lot.
Thanks in advance!!
Regards,
Rogério
I've created an Untyped collection ou array of items to assign to a RadGridView. Everything works well on ReadOnly mode! If I set ReadOnly to false and double click the cell, an exception ("Object reference not set to an instance of an object ") if thrown on method GridViewCell.ShowEditor().
If I use System.Windows.Controls.Data.DataGrid it works fine! If I create a typed collection or list and assign to the grid it works fine!
It seams that RadGridView could not assign a CellEditor (at least a default/generic one) when there's no type defined on Collections!
Here is my code:
<UserControl x:Class="SilverlightApplication23.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"
xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
Width="400" Height="300">
<Grid x:Name="LayoutRoot" Background="White">
<StackPanel>
<telerik:RadGridView IsReadOnly="False" x:Name="dgEntityTypes" AutoGenerateColumns="False">
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn HeaderText="Name" DataMemberBinding="{Binding Name}" />
</telerik:RadGridView.Columns>
</telerik:RadGridView>
<data:DataGrid x:Name="dgEntityTypes2" BorderBrush="Transparent" AutoGenerateColumns="False" IsReadOnly="False" CanUserResizeColumns="False">
<data:DataGrid.Columns>
<data:DataGridTextColumn Header="Name" Binding="{Binding Path=Name}"/>
</data:DataGrid.Columns>
</data:DataGrid>
</StackPanel>
</Grid>
</UserControl>
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
ObservableCollection<Object> mycol = new ObservableCollection<Object>();
Test t1 = new Test();
t1.Name = "aaa";
t1.Id = "111";
Test t2 = new Test();
t2.Name = "aaa";
t2.Id = "111";
mycol.Add(t1);
mycol.Add(t2);
dgEntityTypes.ItemsSource = mycol;
dgEntityTypes2.ItemsSource = mycol;
}
}
public class Test
{
public string Name { set; get; }
public string Id { set; get; }
}
Is there any work-arround for this issue? This is a problem with a huge impact on our application because it's used a lot.
Thanks in advance!!
Regards,
Rogério