views:

121

answers:

1

Hi,

I'll start off with what I want so it may be simpler to understand:

  1. I have a Page (Master.xaml) that has has a listbox of PersonViewModel.
  2. When the user selects a PersonViewModel from the listbox, I want to Navigate to a details (Details.xaml) page of the selected PersonViewModel.
  3. The details page does some extra heavy lifting that I only want done once the user navigates to the page. (I don't want too much stuff loaded in each PersonViewModel of the master listbox)

So how do you guys handle master/detail scenarios with navigation while maintaining "blendability"?

I've been turing in circles for the past week. there seems to be no clean solution for something that should be quite common?

A: 

Found a solution that i'm pretty happy with. When IsInDesignTool is true, I call commands to fake user interactions (Ex: PlayCommand) so when I see the Design area in blend, it's as if the user already fired the command.

public class ViewModelLocator
{
    public ViewModelLocator()
    {
        if (DesignerProperties.IsInDesignTool)
        {
            MainViewModel = new MainViewModel(new GameDataDummy());

            //Fake user interactions
            MainViewModel.PlayCommand.Execute(null);
        }
        else
        {
            MainViewModel = new MainViewModel(new GameData());
        }
    }

    public MainViewModel MainViewModel { get; private set; }

}
vidalsasoon