title: Using new ViewModel each time I open a page
body: <p>I didn't know how better to word the title so I went with solution that came to my mind. </p>
  
  <p>Here is the problem. I have a page that has list and each item on the lists opens a detail page (on click). But the VM is reused, which causes me several problems. </p>
  
  <ul>
  <li><p>Previous data can be seen for split second when opening a the detail page</p></li>
  <li><p>I need certain properties to be set to specific values when the page open, but since the VM is reused it keeps all the values from the previous detail and this messes up my logic.</p></li>
  </ul>
  
  <p>This UWP app. I'm using Template10 framework's NavigationService to move between pages.</p>
  
  <p>Main Page ViewModel</p>
  
  <pre><code>public class MainPageViewModel : ViewModelBase {
      private List&lt;MangaItem&gt; _mangaList;
      public List&lt;MangaItem&gt; mangaList {
          get { return _mangaList; }
          set { Set(ref _mangaList, value); }
      }
  
      private string _mainSearchText;
      public string mainSearchText {
          get { return _mainSearchText; }
          set { Set(ref _mainSearchText, value); }
      }
  
      public MainPageViewModel() {
          _mangaList = new List&lt;MangaItem&gt;();
          mangaList = new List&lt;MangaItem&gt;();
  
          Initialize();
      }
  
      private async void Initialize() {
          mangaList = await MangaListGet.GetListAsync();
      }
  
      public async void MainSearchSubmitted() {
          mangaList = await MangaListGet.GetListAsync(_mainSearchText);
      }
  
      public void MangaSelected(object sender, ItemClickEventArgs e) {
          var mangaItem = (MangaItem)e.ClickedItem;
          NavigationService.Navigate(typeof(Views.MangaDetail), mangaItem.id);
      }
  } 
  </code></pre>
  
  <p>And Detail Page ViewModel</p>
  
  <pre><code>class MangaDetailViewModel : ViewModelBase {
  
      private MangaItem _mangaDetail;
      public MangaItem mangaDetail {
          get { return _mangaDetail; }
          set { Set(ref _mangaDetail, value); }
      }
  
      private string _mangaId;
  
      public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary&lt;string, object&gt; suspensionState) {
          _mangaId = parameter as string;
          Initialize();
  
          await Task.CompletedTask;
      }
  
      private async void Initialize() {
          mangaDetail = await MangaDetailGet.GetAsync(_mangaId);
      }
  
      public void ChapterSelected(object sender, ItemClickEventArgs e) {
          var _chapterId = (ChapterListItem)e.ClickedItem;
          NavigationService.Navigate(typeof(Views.ChapterPage), _chapterId.id);
      }
  }
  </code></pre>
  
  <p>This code only shows the first problem is displaying previously loaded data for a split second. If needed I will add code that showcases the other problem, but I' not sure if it's really relevant right now. I'm thinking that maybe my entire logic is flawed or something.</p>
  
  <p>EDIT:</p>
  
  <pre><code>&lt;Page.DataContext&gt;
      &lt;vm:ChapterPageViewModel x:Name="ViewModel" /&gt;
  &lt;/Page.DataContext&gt;
  </code></pre>
  
  <p>where vm is <code>xmlns:vm="using:MangaReader.ViewModels"</code>.</p>