Prism 4 and Telerik RadDocking

36 posts, 0 answers
  1. Ubuntu
    Ubuntu avatar
    89 posts
    Member since:
    Jul 2012

    Posted 28 Nov 2011 Link to this post

    Hello Dave,

    Thanks for sharing this ...

    I use prism regionManager.RequestNavigation to load the view and I implement the IConfirmNavigationRequest in the VM and it was working fine before I move to RadDock; there I implement the confirmation to close with/out saving to the user and prism takes care of unloading the view VM .

    I have found a work around in the VM, if you are interested;
    foreach (var region in RegionManager.Regions)
                {
                    foreach (var view in region.Views)
                    {
                        if (view is MyDetailsView)
                        {
                            if (((MyDetailsView)view).DataContext == this)
                            {
                                region.Remove(view);
                            }                       
                        }
                    }
                    //if (region.Views.Contains(this)) region.Remove(this);
                }

    I admit its not generic but it does the work & my view is clean from any CodeBehind.

    I am sure your viemodelmanager will be valuable to me, if you can share it as well, will be fabulous.


    EDITED:
    ----------
    small detail I forgot to mention (but important) when using prism navigation, I had to have a default view opened before I actually navigate to any other real view (items data), I put a dummy xaml page with "select item to display its content" text message, this is how I trigger the navigation in prism (just in case)

    Best regards
  2. Dave Smits
    Dave Smits avatar
    8 posts
    Member since:
    Sep 2009

    Posted 28 Nov 2011 Link to this post

    I added an example with the IViewModelRegionManager so if you interessed you can download it. I dont think it will work with the navigation part of prism, but the source is included so you can extend it ;). in this example the mainviewmodel added an leftviewmodel to the iviewmodelregionmanager, the iviewmodelregionmanager retrieves to the viewlocator the right view and adds this view to the iregionmanager. in the leftviewmodel is icloseaware implemented and canclose will call deleteviewmodel
  3. DevCraft banner
  4. Ubuntu
    Ubuntu avatar
    89 posts
    Member since:
    Jul 2012

    Posted 28 Nov 2011 Link to this post

    I completely agree with you that using RadDock is not quite good with prism navigation. It should be handled manually for better results.

    I will have a look at the viewmodelregion manager and give you the feedback.
  5. Dave Smits
    Dave Smits avatar
    8 posts
    Member since:
    Sep 2009

    Posted 28 Nov 2011 Link to this post

    i'm not sure if prism navigation not fits with the raddocking. i never used prism navigation...
  6. Ubuntu
    Ubuntu avatar
    89 posts
    Member since:
    Jul 2012

    Posted 01 Dec 2011 Link to this post

    Hello Dave,

    I was using PRISM navigation through all my modules and everything was working as expected, until I decided to use RadDock and I found there are some tweaks to get it to work.
    Although I am still use the requestNavigation with no problem and its doing its job just fine,anyway your viewmodel looks promising and I will try to implement it in a big scenario to see how it really works.

    One thing; in the close prompt at the Leftview model you still use the old code which doesn't work (doesn't close), I guess you need to call RemoveViewModel or something to get it to work. so I believe the correct code will be:
    public void DoSomethingASync()
            {
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    if (MessageBox.Show("are you sure", "are you sure", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
                    {
                      var regionManager = ServiceLocator.Current.GetInstance<IViewModelRegionManager>();
                        if (regionManager.ContainsViewModel(this))
                        {
                                    regionManager.RemoveViewModel(this);
                        
                    }
                });
      
            }

    I will drill deep in the code to understand it better.

    Thanks for your information & effort
    Regards
  7. Dave
    Dave avatar
    1 posts
    Member since:
    Jul 2013

    Posted 18 Jul 2013 Link to this post

    Hi Dave,

    Firstly - great work!

    Did you manage to get floating windows working? In this version they simply won't appear.

    Thanks
Back to Top
DevCraft banner