1

理解しやすいように、必要なものから始めます。

  1. PersonViewModel のリストボックスを持つページ (Master.xaml) があります。
  2. ユーザーがリストボックスから PersonViewModel を選択すると、選択した PersonViewModel の詳細 (Details.xaml) ページに移動します。
  3. 詳細ページは、ユーザーがページに移動したときにのみ実行したい余分な重い作業を行います。(マスターリストボックスの各 PersonViewModel にあまり多くのものをロードしたくありません)

では、「ブレンド性」を維持しながら、ナビゲーションを使用してマスター/詳細シナリオをどのように処理しますか?

私はこの 1 週間、ぐるぐる回っています。非常に一般的であるべき何かに対する明確な解決策がないように思われますか?

4

1 に答える 1

0

私がかなり満足している解決策を見つけました。IsInDesignTool が true の場合、コマンドを呼び出してユーザー インタラクションを偽装します (例: PlayCommand)。そのため、デザイン エリアがブレンドに表示されると、ユーザーが既にコマンドを実行したかのように見えます。

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

}
于 2010-05-15T14:25:31.247 に答える