Persist view model between theme swaps

This commit is contained in:
Matt Nadareski
2021-07-05 23:09:22 -07:00
parent 0ae58ab21c
commit 7f4992d2d0
2 changed files with 22 additions and 6 deletions

View File

@@ -30,15 +30,27 @@ namespace RedBookPlayer.GUI
/// <summary>
/// Initialize the UI based on the default theme
/// </summary>
public PlayerView() : this(null) { }
public PlayerView() : this(null, null) { }
/// <summary>
/// Initialize the UI based on the default theme with an existing view model
/// </summary>
/// <param name="xaml">XAML data representing the theme, null for default</param>
/// <param name="playerViewModel">Existing PlayerViewModel to load in instead of creating a new one</param>
public PlayerView(PlayerViewModel playerViewModel) : this(null, playerViewModel) { }
/// <summary>
/// Initialize the UI based on the currently selected theme
/// </summary>
/// <param name="xaml">XAML data representing the theme, null for default</param>
public PlayerView(string xaml)
/// <param name="playerViewModel">Existing PlayerViewModel to load in instead of creating a new one</param>
public PlayerView(string xaml, PlayerViewModel playerViewModel)
{
DataContext = new PlayerViewModel();
if(playerViewModel != null)
DataContext = playerViewModel;
else
DataContext = new PlayerViewModel();
PlayerViewModel.PropertyChanged += PlayerViewModelStateChanged;
LoadTheme(xaml);