|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using System.Windows.Input;
using WorldDataLib.Model;
namespace TestTreeViewWithRightBarView.ViewModel
{
/// <summary>
/// This class represesnts the head of the tree
/// </summary>
public class TreeRootViewModel : ITreeViewWithChildrenNode
{
#region Members
IViewModel m_Parent;
ObservableCollection<ITreeViewNode> m_Children;
#endregion
#region Properties
#region ITreeViewWithChildrenNode Members
public ObservableCollection<ITreeViewNode> Children
{
get
{
return m_Children;
}
}
#endregion
#region ITreeViewNode Members
public string Caption
{
get
{
return "Planet Earth";
}
}
#endregion
#region IViewModel Members
public IViewModel VMParent
{
get
{
return m_Parent;
}
}
#endregion
#endregion
#region Methods
#region Ctor
public TreeRootViewModel(IViewModel parent, List<Continent> continents)
{
m_Parent = parent;
m_Children = new ObservableCollection<ITreeViewNode>();
if (continents != null)
{
for (int iter = 0; iter < continents.Count; iter++)
{
m_Children.Add(new ContinentViewModel(this, continents[iter]));
}
}
}
#endregion
#region IViewModel Members
/// <summary>
/// When the event is
/// </summary>
/// <param name="sender"></param>
/// <param name="param"></param>
/// <param name="viewModelEvent"></param>
public void HandleEvent(IViewModel sender, object param, ViewModelOperationsEnum viewModelEvent)
{
if (m_Parent != null)
{
m_Parent.HandleEvent(sender, param, viewModelEvent);
}
}
#endregion
#region GotFocus
public ICommand GotFocus
{
get
{
return new DelegateCommand(this.ControlGotFocus);
}
}
/// <summary>
/// When the control gets focus, an event is fired for external handling
/// </summary>
public void ControlGotFocus()
{
if (VMParent != null)
{
VMParent.HandleEvent(this, null, ViewModelOperationsEnum.GotFocus);
}
}
#endregion
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.