Я работаю над приложением .net wpf для управления последовательными и иерархическими действиями с участием (сверху внизу):
- Main Firstlevel Activity
- FirstLevel activity is divided into SecondLevel activities with their own StartTime and Duration parameters
- Each SecondLevel activity is further divided into ThirdLevel activities with their own StartTime and Duration parameters
. StartTime Свойство только последующих объектов thirdleviewmodel в assectableCollection Когда одна из их продолжительности изменяется, например,: https://i.sstatic.net.net.netn7 -aln7. < /p>
c# кодовые шкалы (упрощенная) < /h2>
steriall -class < /h2>
wornelel.// Derived from BindableBase Class which implements InotifyPropertyChanged
public class SecondLevelViewModel : BindableBase
{
// constructor
public SecondLevelViewModel()
{
// relevant instantiations
ThirdLevels.CollectionChanged += ThirdLevels_CollectionChanged;
foreach (ThirdLevelViewModel thirdLevel in ThirdLevels)
{
thirdLevel.PropertyChanged += thirdLevel_PropertyChanged;
}
}
// properties
public ObservableCollection ThirdLevels
{
// relevant Get and Set accessors
...
}
// CollectionChanged Event Handler
private void ThirdLevels_CollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
{
// switch implementation
...
}
// PropertyChanged Event Handler
private void thirdLevel_PropertyChanged(object? sender, PropertyChangedEventArgs e)
{
// other relevant updates on thirdLevel object's PropertyChanged Event
...
// *** Update StartTime value of subsequent Items in the Collection ***
}
}
класс активности Thirdlevel
// Derived from BindableBase Class which implements InotifyPropertyChanged
public class SecondLevelViewModel : BindableBase
{
// constructor
public SecondLevelViewModel()
{
// relevant instantiations
...
// Updates value of Duration property
// based on Timer property which is a DispatcherTimer object
// called by bound button on UI
...
}
public TimeOnly StartTime
{
get { ... }
set
{
...
OnPropertyChanged();
}
}
public TimeSpan Duration
{
get { ... }
set
{
...
OnPropertyChanged();
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/796 ... changed-ev