English 中文(简体)
可见的学习需要另外三个方法/方案。 是否有其他藏书?
原标题:ObservableCollection needs three more methods/properties. Does some other collection have them?

我对这个扫描机找到适当的收集方法进行了研究。

Here is the signature of my desired ViewModel. There are 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>().

但我们确实需要这样的东西吗? 你们总是能够受“Model.MyCollection/”的约束,以获得目前选定的项目。





相关问题
Reactive Extensions (Rx) + MVVM =?

One of the main examples being used to explain the power of Reactive Extensions (Rx) is combining existing mouse events into a new event representing deltas during mouse drag: var mouseMoves = from ...

Where should the data be stored in MVVM?

I ve got this Silverlight Prism application that is using MVVM. The model calls a WCF service and a list of data is returned. The ViewModel is bound to the View, so the ViewModel should have a List ...

Where to put the calls to WCF or other webservices in MVVM?

I m building Silverlight applicaitions using Prism and MVVM. When calling WCF services on your own server, or even external webservices like the Bing api, would this be done from the Model? or from ...

How to avoid View specific code in my ViewModel

My application has a menu option to allow the creation of a new account. The menu option s command is bound to a command (NewAccountCommand) in my ViewModel. When the user clicks the option to create ...

WPF MVVM User Control binding issues

I have an application that uses MVVM. I have several items on the main window that bind to the ViewModel for that window. When I run it everything works. However, when I add a user control to the main ...

WPF: writing smoke tests using ViewModels

I am considering to write smoke tests for our WPF application. The question that I am faced is: should we use UI automation( or some other technology that creates a UI script), or is it good enough to ...

WPF - MVVM - NHibernate Validation

Im facing a bit of an issue when trying to validate a decimal property on domain object which is bound to a textbox on the view through the viewmodel. I am using NHibernate to decorate my property on ...

热门标签