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

IsSynchronizedWithCurrentItem not supported by the GridView

5 Answers 439 Views
GridView
This is a migrated thread and some comments may be shown as answers.
William
Top achievements
Rank 1
William asked on 31 May 2011, 04:41 AM
Hi,
I am using the 2011 SP 1 release and it does not support the 'IsSynchronizedWithCurrentItem' property. The thread entitled  'Collections of Collections and row select ' from January 2010 states that it would be available in the 2010 Q1 release but this does not appear to have happened. It would be nice if you could reinvestigate this issue because if it was ever implemented then it now seems to be broken. Thanks,
Pete

5 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 31 May 2011, 07:19 AM
Hello William,

I have tested the functionality of the IsSynchronizedWithCurrentItem property and everything seems to work as expected - once it is set to "True", the grid will have its first item selected. I am sending you a sample project so that you can test the case locally.
 

Greetings,
Maya
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
William
Top achievements
Rank 1
answered on 01 Jun 2011, 05:21 AM
Hi Maya,
Unfortunately I only have VS2008 so I can not run the test program that you provided. You mention that the first item is selected but what I didn't see was the selected item change in other controls that were bound to the collection when I selected from the GridView and I didn't see the GridView change its selected item when selected by the other controls. Basically my code was something like this:

<ListBox x:Name="listbox1" ItemsSource="{Binding MyCollection}" IsSynchronizedWithCurrentItem="True" />
<ListBox x:Name="listbox2" ItemsSource="{Binding MyCollection}" IsSynchronizedWithCurrentItem="True" />
<RadGridView x:Name="gridview" ItemsSource="{Binding MyCollection}" IsSynchronizedWithCurrentItem="True" />

and what I was seeing was that the selected item for the listboxes were always in sync with each other but not the selected item for the gridview.

Best regards,
Pete
0
Maya
Telerik team
answered on 01 Jun 2011, 08:42 AM
Hi William,

Generally, this would be the expected behavior since the source for the list boxes is one and the same instance of the CollectionViewSource, while the RadGridView creates its own copy.
What you may do in this case is to follow one of the following approaches:
1. Bind the SelectedItem of the grid and the list boxes to a property in your ViewModel.
2. Set the source of all controls in the code-behind to one and the same ListCollectionView:

var data = Club.GetClubs();
var view = new ListCollectionView(data);
 
this.clubsGrid.ItemsSource = view;
this.listBox1.ItemsSource = view;
this.listBox2.ItemsSource = view;

I am sending you a sample project illustrating both approaches.

 


Greetings,
Maya
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
William
Top achievements
Rank 1
answered on 02 Jun 2011, 06:52 AM
Hi Maya,
Changing the grid view to use the collection view worked perfectly but wouldn't it be better if the grid view used the default collection view instead of creating its own? Thank you very much for the workaround.
Pete
0
Roland
Top achievements
Rank 1
answered on 11 Nov 2011, 05:29 PM
with this convter you use the DefaultView of any list in RadGridView


public class CollectionDefaultViewConverter : IValueConverter
    {
        #region IValueConverter Members
 
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var result = CollectionViewSource.GetDefaultView(value);
            return result ?? value;
        }
 
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value is CollectionView)
                return ((CollectionView)value).SourceCollection;
            else
                return value;
        }
 
        #endregion
    }
Tags
GridView
Asked by
William
Top achievements
Rank 1
Answers by
Maya
Telerik team
William
Top achievements
Rank 1
Roland
Top achievements
Rank 1
Share this question
or