Parent collection is binded to a radGridView with hierarchical gridview structure.
Is there any way to trigger parent property when there is a change in inner collection
Parent Object:
public class CoverHierarchical : EditableModelBase<CoverHierarchical>
{
#region Attribute Declarations
private Int32 m_iId;
private string m_sName = "";
private bool m_bIsChanged;
private ObservableCollection<CoverContentBO> m_oCoverContent;
#endregion
/// <summary>
/// Get or set the id.
/// </summary>
public Int32 Id
{
get { return this.m_iId; }
set
{
if (this.m_iId != value)
{
this.IsChanged = true;
this.m_iId = value;
RaisePropertyChanged("Id");
}
}
}
/// <summary>
/// Get or set the name.
/// </summary>
public string Name
{
get { return this.m_sName; }
set
{
if (this.m_sName != value)
{
this.IsChanged = true;
this.m_sName = value;
RaisePropertyChanged("Name");
}
}
}
/// <summary>
/// Get or set the CoverContent Collection.
/// </summary>
public ObservableCollection<CoverContentBO> CoverContentCollection
{
get { return this.m_oCoverContent; }
set
{
if (this.m_oCoverContent != value)
{
this.IsChanged = true;
this.m_oCoverContent = value;
RaisePropertyChanged("CoverContentCollection");
}
}
}
/// <summary>
/// Get or set the changed flag.
/// </summary>
public bool IsChanged
{
get { return this.m_bIsChanged || this.CoverContentCollection.Any(i=>i.IsChanged); }
set
{
if (this.m_bIsChanged != value)
{
this.m_bIsChanged = value;
RaisePropertyChanged("IsChanged");
}
}
}
#endregion
}
and the Child Object
[Serializable]
public class CoverContentBO : EditableModelBase<CoverContentBO>
{
#region Attribute Declarations
private Int32 m_iCoverId;
private Int32 m_iId;
private bool m_bIsChanged;
#endregion
#region Public Properties
/// <summary>
/// Get or set the cover id.
/// </summary>
public Int32 CoverId
{
get { return this.m_iCoverId; }
set
{
if (this.m_iCoverId != value)
{
this.IsChanged = true;
this.m_iCoverId = value;
RaisePropertyChanged("CoverId");
}
}
}
/// <summary>
/// Get or set the id.
/// </summary>
public Int32 Id
{
get { return this.m_iId; }
set
{
if (this.m_iId != value)
{
this.IsChanged = true;
this.m_iId = value;
RaisePropertyChanged("Id");
}
}
}
/// <summary>
/// Get or set the changed flag.
/// </summary>
public bool IsChanged
{
get { return this.m_bIsChanged; }
set
{
if (this.m_bIsChanged != value)
{
this.m_bIsChanged = value;
RaisePropertyChanged("IsChanged");
}
}
}
#endregion
}
In ViewModel
public ObservableCollection<CoverHierarchical> CoverHierarchicalCollection
{
get { return m_CoverHierarchicalCollection; }
set
{
if (m_CoverHierarchicalCollection != value)
{
m_CoverHierarchicalCollection = value;
OnPropertyChanged();
}
}
}
CoverHierarchicalCollection
is Bound to the view. If user edits the child grid, changes happen in child. Is there any way to trigger IsChanged
property of parent, on changing the Child inner collection (CoverContentCollection
) field.