Help understanding how to navigate child collections

Help understanding how to navigate child collections

Old forum URL: forums.lhotka.net/forums/t/10310.aspx


Hamchuck posted on Wednesday, April 27, 2011

I have an EditableRoot object that contains a EditableChildList of EditableChild objects. I'm using WPF and CSLA 4.1, what I'm having a hard time getting to work is now can I navigate through that ECL using code?  I would like to be able to move the currentitem for the ECL to any of the objects in the ECL.

Is there an example of this somewhere ?

Could someone explain how I can do that ?

 

Thanks

RockfordLhotka replied on Thursday, April 28, 2011

You use the term 'currentitem'. That sounds like the concept of currency, which is a UI concept, not a business layer concept.

Like any .NET collection, the business collection itself has no concept of currency - no concept of a "current item".

WPF provides the CollectionViewSource that "wraps" collections and tracks currency. I suspect that's what you need to be using.

Hamchuck replied on Thursday, April 28, 2011

Thanks for your answer Rocky

It brings up something that I struggle with or don't really understand very well.

If a request comes from the UI to add a child record through to the viewmodel, the viewmodel can create a new child record and insert it into the child collection, but how does the UI get notified of the change and for the UI to take the appropriate action and display the new child record without the viewmodel effecting the CollectionViewSource by moving the currentitem to the new record ?

Rocky could you please offer a suggestion or point me in the right direction ?

 

Thanks for your time

RockfordLhotka replied on Thursday, April 28, 2011

Data binding uses interfaces to interact with the source objects. The source objects must implement the data binding interfaces to fully participate in the binding process. The CSLA .NET base classes implement these interfaces for you.

In the case of a collection, BusinessListBase implements INotifyCollectionChanged, and so raises a CollectionChanged event when appropriate. In reality it inherits from the ObservableCollection<T> type supplied by Microsoft, and that type does most of the event processing.

Copyright (c) Marimer LLC