This is a migrated thread and some comments may be shown as answers.

InvalidOperationException when group/sort one of the two grids binded on one ListCollectionView

4 Answers 88 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Cedric
Top achievements
Rank 1
Cedric asked on 20 Jun 2011, 12:06 PM
Hi,
I've got an error when i try to group my data by using the drag an drop of one of the columnheader. The only thing noticeable is there is two grids binded over one ListCollectionView because the same data are displayed in several place in my application.
I've made a little sample to reproduce the problem, just drag the Name colum header to the group panel or click on it to sort the datas.

I don't understand what's happen :(

- Ced -
public class MainViewModel : ViewModelBase
{
    public MainViewModel()
    {
        this.Items = new ObservableCollection<Toto>();
        this.Items.Add(new Toto { Name = "AAAA", Num = 0 });
        this.Items.Add(new Toto { Name = "BBBB", Num = 1 });
        this.Items.Add(new Toto { Name = "CCCC", Num = 1 });
        this.Items.Add(new Toto { Name = "DDDD", Num = 0 });
        this.Items.Add(new Toto { Name = "EEEE", Num = 1 });
        this.Items.Add(new Toto { Name = "FFFF", Num = 0 });
 
        this.ItemsList = new ListCollectionView(this.Items);           
    }
 
    private ObservableCollection<Toto> Items { get; set; }
    public ListCollectionView ItemsList { get; private set; }
}
 
public class Toto : ViewModelBase
{
    private string name;
    public string Name
    {
        get { return name; }
        set { name = value; this.RaisePropertyChanged("Name"); }
    }
 
    private bool isSelected;
    public bool IsSelected
    {
        get { return isSelected; }
        set { isSelected = value; this.RaisePropertyChanged("IsSelected"); }
    }
 
    private int num;
 
    public int Num
    {
        get { return num; }
        set { num = value; }
    }
         
}
 
<Window x:Class="MvvmLight1.MainWindow"
        Title="MainWindow"
        Height="300"
        Width="400">
    <Window.Resources>
        <ResourceDictionary>
            <Style TargetType="{x:Type telerik:GridViewRow}"
                   x:Uid="Style_6">
                <Setter x:Uid="Setter_19"
                        Property="IsSelected"
                        Value="{Binding IsSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                <Style.Triggers>
                    <Trigger x:Uid="Trigger_3"
                             Property="IsSelected"
                             Value="True">
                        <Setter x:Uid="Setter_20"
                                Property="Background"
                                Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" />
                    </Trigger>
                </Style.Triggers>
            </Style>
        </ResourceDictionary>
    </Window.Resources>
 
    <StackPanel>
        <Grid x:Name="LayoutRoot"
              HorizontalAlignment="Stretch"
              VerticalAlignment="Stretch">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <telerik:RadGridView AutoGenerateColumns="true"
                                 HorizontalContentAlignment="Stretch"
                                 VerticalContentAlignment="Stretch"
                                 Name="Grid1"
                                 SelectionMode="Extended"
                                 ScrollViewer.IsDeferredScrollingEnabled="True"
                                 EnableRowVirtualization="True"
                                 RowDetailsVisibilityMode="Collapsed"
                                 ItemsSource="{Binding ItemsList}"/>
 
            <telerik:RadGridView Grid.Column="1"
                                 AutoGenerateColumns="true"
                                 HorizontalContentAlignment="Stretch"
                                 VerticalContentAlignment="Stretch"
                                 Name="Grid2"
                                 SelectionMode="Extended"
                                 ScrollViewer.IsDeferredScrollingEnabled="True"
                                 EnableRowVirtualization="True"
                                 RowDetailsVisibilityMode="Collapsed"
                                 ItemsSource="{Binding ItemsList}"/>
        </Grid>
    </StackPanel>
</Window>

4 Answers, 1 is accepted

Sort by
0
Accepted
Dimitrina
Telerik team
answered on 23 Jun 2011, 02:01 PM
Hello Cedric,

I have created a sample project in order to reproduce the behavior that you describe (I am using the code that you have pasted). Unfortunately I was not able to.

May you please review the project that I have used for testing, and correct me where I am doing wrong trying to reproduce this InvalidOperationException?

Greetings,
Didie
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Cedric
Top achievements
Rank 1
answered on 23 Jun 2011, 03:23 PM
-- snip --
0
Cedric
Top achievements
Rank 1
answered on 23 Jun 2011, 04:14 PM
Hi Didie,

i can reproduce the problem with your project by referencing the telerik version on my computer : Dll version are 2010.2.924.40.
If i use you Dll i see no problem.

- Mins -
0
Cedric
Top achievements
Rank 1
answered on 04 Jul 2011, 02:18 PM
I've updated to the last version of RadControl, and it solves my problem.

Thx

- Cedric -
Tags
GridView
Asked by
Cedric
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Cedric
Top achievements
Rank 1
Share this question
or