I have a project in winrt environment where I am trying to extend the functionality of a standard GridView control by expanding it. The goal is to change the behavior of SelectedItems in a GridView.
public class myGridView : GridView { /// <summary> /// My replacement of SelectedItems /// </summary> public IObservableVector<object> appItems { get { return GetValue(AppSelectedItemsProperty) as IObservableVector<object>; } set { SetValue(AppSelectedItemsProperty, value); appItems.VectorChanged += AppSelectedItemsChanged; } } /// <summary> /// Identifies the AppSelectedItems dependency property. /// </summary> public static readonly DependencyProperty AppSelectedItemsProperty = DependencyProperty.Register( "appItems", typeof(IObservableVector<object>), typeof(AppGridView), new PropertyMetadata(null, AppItemsPropertyCallback)); β¦. β¦. ... }
In my XAML file, I have the following.
<xx β¦β¦. <appControls:AppGridView appItems="{Binding ContactsListSelectedItems, Mode=TwoWay } }"> .β¦ β¦ </appControls:AppGridView > β¦.. β¦β¦. /xx>
The last part of the code is my MVVM class bound to the Datacontext.
public class myModel: baseModel { β¦β¦ β¦β¦..
I found the implementation of IObservableVector here: https://gist.github.com/runceel/2437074
Binding data with ContactsListSelectedItems does not work, indicating the following error:
Error: Cannot get 'ContactsListSelectedItems' value (type 'Object') from type 'Consius.ActiveWork.Pages.ContactPage.ContactPageViewModel, Consius.ActiveWork, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. BindingExpression: Path='ContactsListSelectedItems' DataItem='Consius.ActiveWork.Pages.ContactPage.ContactPageViewModel, Consius.ActiveWork, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'; target element is 'Consius.ActiveWork.Controls.AppGridView' (Name='ContactsList'); target property is 'appItems' (type 'IObservableVector`1<Object>').
If I changed the type of ContactsListSelectedItems to:
IObservableVector<object>
Everything works well.
This is not an acceptable solution for me by writing my MVVM class using a class object.
Is there anyone there who can give me a clue what is wrong?