Closing a view?

Sep 5, 2008 at 1:52 PM
We're building a CompositeWPF app delivered via xbap to internal customers. We're taking the road of driving it using an inductive UI so everything is a task right now. Tasks load up into a main region where the user selects them. That would launch the view/presentationmodel for that task so we're emulating a modal type of view (you only work on that screen and when you're done you go back to the home screen).

I'm not quite sure how to finish the task and remove the view? I don't want to do this in the presentation model as it doesn't really control the view and we're trying to keep our views uber-thin with only xaml markup (i.e. no code so far). The closing would be triggered by say a button or something, I'm just not sure in CompositeWPF how to close the view as it seems to want to keep the view around for the lifetime of the app.
Sep 5, 2008 at 2:52 PM
Hi bsimser,  in the source code example in this message thread I show how to remove a view.  On the click of a button the view is moved to a different region; to do this it removes it from the current region. 

In case you are not aware - XBAP runs in partial trust, but not when running from the debugger.   I Blog on the topic HERE.

Sep 8, 2008 at 10:04 PM

Thanks. Looks good. We're doing something like that now. One wrikle that I'm trying to figure (which might be more WPF than CAF). In our user control we have a way to close the view (which calls a method on the PresentationModel). We've separated out our presentation model and view so the two don't know about each other (blog on this coming soon) so we only do binding in the xaml to presentation model methods.

In our xaml I have something like this:

            <TextBlock Width="auto" Margin="50">All your base are belong to us.</TextBlock>
            <Button Margin="10"
                    Content="Click Me To Close This View"
                    Command="{Binding models.CreateSubmissionPresentationModel.Close}"
                    CommandParameter="{Binding Self}"/>

So there's a method on our presentation model called Close which calls a DelegateCommand to execute. It needs the view to be passed into it but a) I'm not sure if I can pull the view class out of the xaml (it's there in the declaration of the user control) and b) the fire event doesn't seem to be called.

I'm sure it's a xaml mismatch but not sure.
Sep 9, 2008 at 2:51 AM
I provide XAML, source w/flash demo showing how to set the CommandParameter to the View's reference so that you can close it from the Presentation Model.

Blogged about HERE .
Sep 9, 2008 at 1:33 PM

That's great. Exactly what I need. Much appreciated!