я новичок в WPF MVVM
У меня есть 3 класса здесь (все классы имеют одинаковый BaseParent):
---- Проблема ---->
Всякий раз, когда я устанавливаю свой BaseParents GroupContent в [DPropertyViewModel], он не обновляет мой ConsoleText в [DConsoleViewModel].
Модель:
public class BaseDParent
{
public string GroupType { get; set; } = "None";
public string GroupName { get; set; } = "None";
public string GroupContent
{
get => _groupcontent;
set
{
_groupcontent = value;
SetContent();
}
}
private string _groupcontent;}
ViewModel:
public class DConsoleViewModel : DNotify
{
public BaseDParent DElement
{
get => _delement;
set
{
_delement = value;
NotifyPropertyChanged();
}
}
private BaseDParent _delement;
public string ConsoleText
{
get => DElement.GroupContent;
set
{
DElement.GroupContent = value;
NotifyPropertyChanged();
}
}}
и вот где я могу изменить свой BaseParents GroupContent:
public class DPropertyViewModel : DNotify
{
public BaseDParent DElement
{
get => _delement;
set
{
_delement = value;
NotifyPropertyChanged();
}
}
private BaseDParent _delement;
public string Level { get; set; } = "0";
public string Property { get; set; } = "Property";
public string Value { get; set; } = "-Null-";
public void SetDElementPropertyValue()
{
string startline = " " + DElement.GroupType + " " + DElement.GroupName + DHelper.NewLine();
string subpropline = DHelper.NewLine() + Level + " " + Property + " ";
int start = DElement.GroupContent.IndexOf(startline);
int propstart = DElement.GroupContent.IndexOf(subpropline, start - 3) + subpropline.Length;
int propnext = DElement.GroupContent.IndexOf(DHelper.NewLine(), propstart);
string propvalue = DElement.GroupContent.Substring(propstart, propnext - propstart);
string toremove = subpropline + propvalue + DHelper.NewLine();
int toaddindex = DElement.GroupContent.IndexOf(toremove);
DElement.GroupContent = DElement.GroupContent.RemoveSub(toremove);
string toadd = subpropline + Value + DHelper.NewLine();
DElement.GroupContent = DElement.GroupContent.Insert(toaddindex, toadd);
}
}
Спасибо за вашу помощь:)