Mvvm ObservableCollection还需要三个方法/属性。其他收藏有吗?
我找了一下,找不到合适的收藏品 这是我想要的ViewModel的签名。有一些有趣的故事 替代品是David Hill的CollectionViewModel或TKey的ObservableDictionary,以及codeplex上的TValue。但是现在,我想要一个内置的SL4集合来处理这个问题。谢谢Mvvm ObservableCollection还需要三个方法/属性。其他收藏有吗?,mvvm,silverlight-4.0,mvvm-light,Mvvm,Silverlight 4.0,Mvvm Light,我找了一下,找不到合适的收藏品 这是我想要的ViewModel的签名。有一些有趣的故事 替代品是David Hill的CollectionViewModel或TKey的ObservableDictionary,以及codeplex上的TValue。但是现在,我想要一个内置的SL4集合来处理这个问题。谢谢 public class myViewModel: INotifyPropertyChanged { public ObservableCollection<MyDataType&
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;}
没有提供此功能的内置集合。但是,您可以将currentIndex值作为私有int存储在ViewModel中,并在当前索引方法中引用它,以及在CurrentItem中使用它。但是我们真的需要这样的东西吗?您可以始终绑定到ViewModel.MyCollection/以获取当前选定的项目正如我所说,编程是对我愚蠢行为的探索。我正在寻找一个名为“Item”之类的方法。现在,作为对你答案的回应,我再次看了看,发现ObservableCollection有一个索引器!var anItem=myCollection[7];谢谢