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

Sync with ICollectionView does not work in version 2011.2.712.35

1 Answer 96 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Nicole
Top achievements
Rank 1
Nicole asked on 02 Sep 2011, 11:39 AM
Hey guys,

I'm trying to sync my selected gridview row with the ICollectionView. I have installed an older version (2010.2.924.35) and the new version 2011.2.712.35. The same implementation works with the older version and don't works with the new version.

So, let have a look at my code:

The code of the ViewModel:

#region Deklarationen
private ObservableCollection<RWF_GUI_TransferItems> _Items;
/// <summary>
/// Enthält alle Elemente die in dem GridView dargestellt werden.
/// </summary>
public ObservableCollection<RWF_GUI_TransferItems> Items
{
    get { return _Items; }
    set {
            _Items = value;
            this.ValueChanged("Items");
        }
}
 
 
private ICollectionView _ItemsView;
/// <summary>
/// View zur Überwachtung des aktuellen Grid-Items
/// </summary>
public ICollectionView ItemsView
{
    get { return _ItemsView; }
    set {
            _ItemsView = value;
            this.ValueChanged("ItemsView");
        }
}
 
 
private RWF_GUI_TransferItems _AktuelleGridAuswahl;
/// <summary>
/// Aktuelle Gridzeile
/// </summary>
public RWF_GUI_TransferItems AktuelleGridAuswahl
{
    get { return _AktuelleGridAuswahl; }
    set {
            _AktuelleGridAuswahl = value;
            this.ValueChanged("AktuelleGridAuswahl");
        }
}
 
public MainViewModel()
{
    this.Items = new ObservableCollection<RWF_GUI_TransferItems>();
 
    this.ItemsView = CollectionViewSource.GetDefaultView(this.Items);
    this.ItemsView.CurrentChanged += new EventHandler(OnCurrentItemChanged);
}
 
 
void OnCurrentItemChanged(object sender, EventArgs e)
{
    this.AktuelleGridAuswahl = (RWF_GUI_TransferItems)this.ItemsView.CurrentItem;
}

The XAML-Code:

<telerik:RadGridView ItemsSource="{Binding ItemsView}"
                     RowHeight="25"
                     CanUserFreezeColumns="False"
                     AutoGenerateColumns="False"
                     ShowColumnFooters="true"
                     x:Name="GridViewMain" IsSynchronizedWithCurrentItem="True"
                     IsEnabled="{Binding AtWork, Converter={StaticResource NegateBoolConverter}}">

The Items the ItemsView contains are correctly displayed in the GridView. But the OnCurrentItemChanged-Event is only being raised on startup (this.ItemsView.CurrentItem is null at this moment).

What can I do to get it work?

Thank you very much!
Best regards from Germany



1 Answer, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 08 Sep 2011, 09:26 AM
Hello Josef,

 I have created a sample project following your code snippets. Unfortunately I was not able to reproduce the behavior that you have described. On my end the OnCurrentItemChanged-Event is being raised every time I select a row in the GridView.

Please check the sample project and change it so that the problem is reproduced. That way we could investigate it further.

Thank you for your cooperation.

All the best,
Didie
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

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