Good Morning,
so i have spent the last 4 days getting my knowledge up on mvvm pattern,
however i have been unable to get the desired result back
so figured out why i could not load data into my datagrid,
this has now been resolved,
however i want to select a row and edit a value in one of the data grid values,
and receive an update from with all values on that row,
i have managed to create a selected Pump and wire that too selected row command,
this returns the selected row,
result
however, this is before i edit it and after i edit it does not update unless i go off the row and back onto it witch is not what i want,
so i have added a on property changed event in my pumptype class,
private int _PumpNo;
public int PumpNo
{
get { return _PumpNo; }
set
{
_PumpNo = value;
OnPropertyChanged("PumpNo");
}
}
private int _State;
public int State
{
get { return _State; }
set
{
_State = value;
this.OnPropertyChanged("State");
}
}
private int _Stan;
public int Stan
{
get { return _Stan; }
set
{
_Stan = value;
this.OnPropertyChanged("Stan");
}
}
private int _GradeId;
public int GradeId
{
get { return _GradeId; }
set
{
_GradeId = value;
OnPropertyChanged("GradeId");
}
}
private string _GradeName;
public string GradeName
{
get { return _GradeName; }
set
{
_GradeName = value;
OnPropertyChanged("GradeName");
}
}
private int _Ppu;
public int Ppu
{
get { return _Ppu; }
set
{
_Ppu = value;
OnPropertyChanged("Ppu");
}
}
private int _Volume;
public int Volume
{
get { return _Volume; }
set
{
_Volume = value;
OnPropertyChanged("Volume");
}
}
private int _Cash;
public int Cash
{
get { return _Cash; }
set
{
_Cash = value;
OnPropertyChanged("Cash");
}
}
private bool _MobileTransaction;
public bool MobileTransaction
{
get { return _MobileTransaction; }
set
{
_MobileTransaction = value;
OnPropertyChanged("MobileTransaction");
}
}
private bool _MobileEnabled;
public bool MobileEnabled
{
get { return _MobileEnabled; }
set
{
_MobileEnabled = value;
OnPropertyChanged("MobileEnabled");
}
}
and then tryied to create a call in the constructor
for when the property is changed. in the class that does work the onproperty changed is trigged in the pumptype class
however the implication in the mainviewmodel class does not get hit when this is changed
public MainWindowViewModel()
{
elfendb.InitialzePumps();
Pumps = new ObservableCollection<PumpType>();
elfenliedpump.PropertyChanged += Elfenliedpump_PropertyChanged;
foreach (var item in elfendb.Pumps)
{
Pumps.Add(item);
}
}
private void Elfenliedpump_PropertyChanged(object? sender, PropertyChangedEventArgs e)
{
int statenumber = 0;
if (e.PropertyName == "State")
RaisePropertyChanged("statenumber");
}
however when the property changes in pumptype class this does not trigger on on the made methord does not even enter it
and have break pointed the state on pumptype and when i change this it does get flagged in pumptype but does not send this down to the mainwindowviewmodel
anyone have any idea why it would do this.
What I have tried:
i have also tried to do the cell edit from the code behind but decided against that as its not true mvvm and spend days on trying to do this i even installed
mvvm toolkit and tried to send the message but as i subscribe multiple times as all pumps values are in a observable collection gets called multiple times and the weakrevrencemessanger throws up an exception saying already subscribed to had to forget this one
any help would be much appreciated kind regards,
elfenliedtopfan5