customizing settingsflyout

Dec 1, 2014 at 9:51 PM
Hello,
Thanks for the great work

Im using this framework to build a winrt app, and i reached the need to have a settingsflyout based on style mvvm with the possibility to wire up the model to the view etc

Is it something provided out of the box that i missed somehow or ?

Thanks
Coordinator
Dec 1, 2014 at 10:04 PM
Hi MouradK,

There actually is some support built in the framework for flyouts. I can't tell you the exact syntax off the top of my head but when I get home this evening I'll do a little research and post an answer

-Ian
Coordinator
Dec 2, 2014 at 12:37 AM
Ok after doing a little research I remembered that the example app covers how to do a settings flyout.

https://stylemvvm.codeplex.com/SourceControl/latest#Examples/ExampleApp/

If you have any specific questions once you look at the example let me know.

-Ian
Dec 3, 2014 at 11:50 AM
Ok Thanks

I'll have a look at that :)
Coordinator
Dec 3, 2014 at 5:10 PM
You should be able to grab the source and run the example app. It covers the setting charm and a number of other use cases.
Dec 4, 2014 at 9:21 AM
Edited Dec 4, 2014 at 9:21 AM
Hello Again

I managed to get it working !!, thanks for the exampleApp : )

One question remains :
I'm using the settingscharm control as a mainregion to which i will inject different views depending on a context.
I have a need to inject a view to that region + a parameter. I was hoping that calling region.Navigate("viewname", parameter) will do it but
the navigationparameter that i got on the OnNavigateTo method is always null.

I was then trying to use the Context property of the region to pass that parameter but its a readonly property...

Any help on that ?

Thanks
Coordinator
Dec 4, 2014 at 12:30 PM
Hmmm, I'm a little surprised that the parameter didn't come through. If you can put together a little example app showing what you are doing and I can debug it and figure out what's wrong.

-Ian
Dec 4, 2014 at 9:59 PM
Edited Dec 4, 2014 at 10:00 PM
Hello,

Ive attached a sample for repro.

As you will see in the settingcharm control view, i defined a "mainregion2" to which i'm injecting a child view using the region.navigate(viewname, parameter) way
When overriding the onnavigateto on the child view, i see that the parameter is not set.

https://drive.google.com/file/d/0B85aV9EwIcssZFdpV25UQklLUjg/view?usp=sharing
Coordinator
Dec 4, 2014 at 11:11 PM
Hi mouradk,

I should have some time this weekend to take a look. Hopefully it's something simple that doesn't require a new release.

-Ian
Dec 5, 2014 at 12:33 PM
Hi Ian

Ok thx : )
Coordinator
Dec 8, 2014 at 2:59 PM
Hi mouradK,

I actually didn't get a chance to look at that this weekend. I'm trying to finish up some other code I've been working on and I got bogged down with that. I'll see if I can get a chance to look this week. December is just always a very busy month.

Sorry
-Ian
Coordinator
Dec 17, 2014 at 2:27 AM
Hi mouradk,

Sorry I took so long getting back to you. I've debugged your example and it is a bug. I see where the problem is and the fix is not to hard. I'll see about doing a release at some point in the coming week or two. I have a little bit of a problem in that I need to do the release by hand as the build machine where I was building has since been lost (sadly it has to be built on a windows 8 machine and there aren't any public build systems that can build it).

-Ian
Mar 6, 2015 at 3:33 PM
Edited Mar 6, 2015 at 3:33 PM
For the benefit of anyone else stumbling across this via Google and sad that this is still not fixed, here is a shim:
using StyleMVVM.Suspension;
using StyleMVVM.View;
using StyleMVVM.ViewModel;

  /// <summary>
  ///   There is an annoying bug in the StyleMVVM framework which prevents the Parameter property
  ///   in StyleNavigationEventArgs from being used to pass parameters for navigation.  Although
  ///   it's been identified for ages (https://stylemvvm.codeplex.com/discussions/573747) there 
  ///   has been no development work on the framework for nearly as long...  :-(
  /// 
  ///   The bug:
  ///     * Calling Region.NavigateTo( [regionname], [parameter] ) dives into the StyleMVVM codebase
  ///       and eventually calls ContentPresenterAdaptor.CallNavigatedTo(...)
  ///     * Here the NavigationParameter property of the viewmodel is set to the parameter value, and
  ///       calls NavigatedTo with an empty StyleNavigationEventArgs :-(
  ///     * This calls StyleMVVM.CSharp.ViewModel.NavigatingViewModel.NavigatedTo(), which then *populates* 
  ///       NavigationParameter *from* the (empty!) StyleNavigationEventArgs, thereby losing the 
  ///       data altogether
  /// 
  ///   It would be preferable for this to be fixed in the framework, of course, but that seems unlikely,
  ///   so this shim just reimplements the offending method to produce the 'correct' behaviour.
  /// </summary>
  public class FixedRegionAwareViewModel : RegionAwareViewModel,
    INavigationViewModel
  {
    /// <summary>
    ///   Fixes NavigatingViewModel.NavigatedTo()
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    void INavigationViewModel.NavigatedTo(object sender, StyleNavigationEventArgs e)
    {
      if(this.attemptToResumeOnNavigate)
      {
        string tempKey = this.SyncKey;

        if(!string.IsNullOrEmpty(tempKey))
        {
          SyncService.Instance.ResumeWithContext(this, tempKey);
        }
        else
        {
          SyncService.Instance.Resume(this);
        }
      }

      this.OnNavigatedTo(sender,
                         new StyleNavigationEventArgs()
                         {
                           Parameter = this.NavigationParameter
                         });
    }
  }

Coordinator
Mar 6, 2015 at 4:36 PM
Thanks for posting this. I've been busy with life and other things.

If you would be interested in making a pull request with the fix it would be much appreciated.

-Ian