Hello All,
ran into a snag that i have never ran into before,
so i am trying to talk between multiple view models and have the current stuff that is being edited displayed on the screen that i managed to setup,
the issue i have is the binding to the string property i created telling me it cant bind to it due to the signature not being accepted
what i have
ViewModelBase Class
public static event EventHandler<string> MyStaticPropertyChanged;
private static string _myStaticProperty;
public static string MyStaticProperty
{
get { return _myStaticProperty; }
set
{
_myStaticProperty = value;
MyStaticPropertyChanged?.Invoke(null, value);
}
}
this is just a place holder that is why i named it my static property ,
in PumpModelViewModel
public void UpdatePumpState(PumpStateModel updatedPumpState)
{
try
{
OnStringUpdated(null, "Test String");
StringUpdatedEvent.RaiseStringUpdated(ViewModelBase.MyStaticProperty);
pumpstatemodel.savepump(updatedPumpState);
}
catch(Exception ex)
{
MessageBox.Show("Error 12 Found In UpdatePumpState " + ex.Message);
}
}
the on string updated method,
private void OnStringUpdated(object sender, string updatedString)
{
ViewModelBase.MyStaticProperty = updatedString;
}
then in the MainViewModel
in the constuctor,
ViewModelBase.MyStaticPropertyChanged += OnMyStaticPropertyChanged;
private void OnMyStaticPropertyChanged(object sender, string e)
{
OnPropertyChanged(nameof(MyStaticProperty));
}
public string MyStaticProperty
{
get { return ViewModelBase.MyStaticProperty; }
set { ViewModelBase.MyStaticProperty = value; }
}
then i bind to the above MyStaticPropery and i get the following error ,
Cannot bind to the target method because its signature is not compatible with that of the delegate type.
any help would be much appreciated.
What I have tried:
Searched on internet and other forms but not able to find a resolve for this issue.