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