开发者

MVVM - Master/Detail scenario with Navigation and Blendability

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 开发者_JAVA百科(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?


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; }

}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜