Fix cloning of SettingsViewModels.
This commit is contained in:
parent
d0be7524d3
commit
286ddb1641
@ -66,6 +66,7 @@ namespace Tests.ViewModels
|
|||||||
Assert.AreNotSame(orig.RevealModelObject(), copy.RevealModelObject());
|
Assert.AreNotSame(orig.RevealModelObject(), copy.RevealModelObject());
|
||||||
|
|
||||||
Assert.AreEqual(String.Format("Kopie von {0}", orig.Name), copy.Name);
|
Assert.AreEqual(String.Format("Kopie von {0}", orig.Name), copy.Name);
|
||||||
|
Assert.IsTrue(copy.IsSelected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -182,8 +182,7 @@ namespace zaaReloaded2.ViewModels
|
|||||||
foreach (Settings s in repository.SettingsList)
|
foreach (Settings s in repository.SettingsList)
|
||||||
{
|
{
|
||||||
SettingsViewModel vm = new SettingsViewModel(s);
|
SettingsViewModel vm = new SettingsViewModel(s);
|
||||||
vm.PropertyChanged += SettingsViewModel_PropertyChanged;
|
AddSettingsViewModel(vm);
|
||||||
SettingsList.Add(vm);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,8 +267,10 @@ namespace zaaReloaded2.ViewModels
|
|||||||
if (Selected != null)
|
if (Selected != null)
|
||||||
{
|
{
|
||||||
SettingsViewModel copy = Selected.Clone() as SettingsViewModel;
|
SettingsViewModel copy = Selected.Clone() as SettingsViewModel;
|
||||||
SettingsList.Add(copy);
|
|
||||||
_repository.SettingsList.Add(copy.RevealModelObject() as Settings);
|
_repository.SettingsList.Add(copy.RevealModelObject() as Settings);
|
||||||
|
AddSettingsViewModel(copy);
|
||||||
|
Selected.IsSelected = false;
|
||||||
|
copy.IsSelected = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -300,6 +301,17 @@ namespace zaaReloaded2.ViewModels
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds a settings view model to the collection and wires the
|
||||||
|
/// PropertyChanged event.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="settingsViewModel">SettingsViewModel to add.</param>
|
||||||
|
void AddSettingsViewModel(SettingsViewModel settingsViewModel)
|
||||||
|
{
|
||||||
|
settingsViewModel.PropertyChanged += SettingsViewModel_PropertyChanged;
|
||||||
|
SettingsList.Add(settingsViewModel);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Implementation of ViewModelBase
|
#region Implementation of ViewModelBase
|
||||||
|
Loading…
Reference in New Issue
Block a user