Fix SettingsViewModelTest.CannotAddChildElementToFormatElement.
This commit is contained in:
parent
14b09f89c5
commit
db8f88c563
@ -58,7 +58,7 @@ namespace Tests.ViewModels
|
||||
parent.IsSelected = true;
|
||||
Assert.IsTrue(_settingsVM.AddChildElementCommand.CanExecute(null));
|
||||
FormatElementViewModel child = new FormatElementViewModel(new Items());
|
||||
parent.AddChildElement(child);
|
||||
_settingsVM.AddChildElementViewModel(parent, child);
|
||||
parent.IsSelected = false;
|
||||
child.IsSelected = true;
|
||||
Assert.IsFalse(_settingsVM.AddChildElementCommand.CanExecute(null));
|
||||
|
@ -31,7 +31,9 @@ namespace zaaReloaded2.Controller.Elements
|
||||
/// </summary>
|
||||
public IList<FormatElementBase> FormatElements { get; private set; }
|
||||
|
||||
public ControlElementBase() { }
|
||||
public ControlElementBase()
|
||||
: this(new List<FormatElementBase>())
|
||||
{ }
|
||||
|
||||
public ControlElementBase(IList<FormatElementBase> formatElements)
|
||||
{
|
||||
|
@ -26,24 +26,26 @@ using System.Collections.ObjectModel;
|
||||
|
||||
namespace zaaReloaded2.ViewModels
|
||||
{
|
||||
class ControlElementViewModel : ElementViewModel
|
||||
public class ControlElementViewModel : ElementViewModel
|
||||
{
|
||||
#region Properties
|
||||
|
||||
public ObservableCollection<ElementViewModel> Elements
|
||||
{
|
||||
get { return null; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets a collection of child ElementViewModels.
|
||||
/// </summary>
|
||||
public ObservableCollection<ElementViewModel> Elements { get; protected set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
public ControlElementViewModel() : base() { }
|
||||
public ControlElementViewModel() : this(null) { }
|
||||
|
||||
public ControlElementViewModel(ControlElementBase controlElement)
|
||||
: base(controlElement)
|
||||
{ }
|
||||
{
|
||||
Elements = new ObservableCollection<ElementViewModel>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -24,7 +24,7 @@ using zaaReloaded2.Controller.Elements;
|
||||
|
||||
namespace zaaReloaded2.ViewModels
|
||||
{
|
||||
class FormatElementViewModel : ElementViewModel
|
||||
public class FormatElementViewModel : ElementViewModel
|
||||
{
|
||||
#region Public properties
|
||||
|
||||
|
@ -218,6 +218,17 @@ namespace zaaReloaded2.ViewModels
|
||||
Elements.Add(elementViewModel);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Wires the OnProperty changed event of an ElementViewModel's
|
||||
/// wrapped model and adds the view model as a child of another
|
||||
/// view model.
|
||||
/// </summary>
|
||||
public void AddChildElementViewModel(ControlElementViewModel parent, FormatElementViewModel child)
|
||||
{
|
||||
child.PropertyChanged += ElementViewModel_PropertyChanged;
|
||||
parent.AddChildElement(child);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private methods
|
||||
@ -246,7 +257,7 @@ namespace zaaReloaded2.ViewModels
|
||||
void ElementViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||
{
|
||||
ElementViewModel vm = sender as ElementViewModel;
|
||||
if (vm != null)
|
||||
if (vm != null && e.PropertyName == "IsSelected")
|
||||
{
|
||||
SelectedElement = vm.IsSelected ? vm : null;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user