开发者

ObservableCollection needs three more methods/properties. Does some other collection have them?

I have looked around a bit for this--can't find the proper collection

Here is the signature of my desired ViewModel. There ar开发者_StackOverflow社区e some interesting alternatives out there David Hill's CollectionViewModel or ObservableDictionary(Of TKey, TValue) on codeplex. But for now, I would like a built-in collection (for SL4) that handles this. Thanks

public class myViewModel: INotifyPropertyChanged
{
    public ObservableCollection<MyDataType> MyCollection;
    private ObservableCollection<MyDataType> _myCollection;

    public CurrentItem<MyDataType>() { return _myCollection.CurrentItem;} 

    public int GetCurrentIndex()  { return _myCollection.CurrentIndex;}
    public SetCurrentIndex(int Index)   { _myCollection.CurrentIndex = Index;}


There isn't a built-in collection that provides this. However, you could just store the currentIndex value as a private int inside your ViewModel, and refer to it for the current index methods, as well as use it for CurrentItem<T>().


But do we really need something like this? You can always bind to "ViewModel.MyCollection/" to get the currently selected item

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜