CSLA .NET

Vibrant discussion about CSLA .NET and using the framework to build great business applications.

Forum has moved

New location: CSLA .NET forum


CSLA .NET Resources:
  • CSLA .NET forum
  • CSLA .NET home page
  • Binding multiple views to a single BO

    rated by 0 users
    Not Answered This post has 0 verified answers | 0 Replies | 0 Followers

    Top 200 Contributor
    44 Posts
    c_manboy posted on Tue, Apr 9 2013 11:14 AM

    I'm doing some multiple bindings to a single BO in WPF and would appreciate some feedback in case I'm going down a bad path.

    I have created a "ViewModelConductor(of M)" which will import child "ViewModel(of M)".  The conductor will be responsible for the fetch/save/cancel/etc. and for setting the child ViewModel's model property. So far everything works very well.  Fetch sets all child model properties, and save calls ApplyEdit on all child model properties followed by a beginsave on the conductor model. 

    (I should add that my viewmodel(of M) is cslacontrib screenwithmodel(of M) for use with caliburn micro.  And my conductor is really a modification of CM conductor class which conducts the screenwithmodel class and contains its own model property).

    My issue is with Cancel.  Depending on various combinations of canceledit and beginedit, cancel will either work periodically or fail outright.  Either way it fails to work consistently.

    I read this post which states that n-level undo is unsupported in these scenarios.  But in this post I read that v4 supports multiple binding scenarios.

    My current workaround is this method on my conductor DoCancel override:

              For Each item In Me.Items
                        If item.IsScreenCreated Then
                            Dim screen = TryCast(item.Screen, ScreenWithModel(Of TModel))
                            If screen IsNot Nothing AndAlso screen.Model IsNot Nothing Then
                                Dim undoable = TryCast(screen.Model, ISupportUndo)
                                If undoable IsNot Nothing Then
                                    undoable.CancelEdit()
                                End If
                                screen.Model = Nothing
                            End If
                        End If
                    Next
                    'call canceledit and beginedit on conductor model
                    MyBase.DoCancel()
                   'set children model property to conductor model
                   ChangeModel(NothingMe.Model)
    
    

    This code seems to work, but I would appreciate any feedback concerning this process.

    Page 1 of 1 (1 items) | RSS

    Copyright (c) 2006-2014 Marimer LLC. All rights reserved.
    Email admin@lhotka.net for support.
    Powered by Community Server (Non-Commercial Edition), by Telligent Systems