Click here to Skip to main content
15,746,107 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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; }
        _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)
    //var index = Pumps.IndexOf(updatedPumpState);
    //if (index >= 0)
    //    Pumps[index] = updatedPumpState;

    // test to see if i can update the database with mvvm patterne

    // lets call the update methord
        OnStringUpdated(null, "Test String");
    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)

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.
Richard Deeming 12-Apr-23 4:15am    
Which line of the code you've posted shows that error?
Gerry Schmitz 12-Apr-23 12:16pm    
You have a static and a property both named the same; and show no XAML bindings. Yes; things are confused. At the very least, name them differently so you're "sure" where you're coming from.
RainHat 14-Apr-23 4:01am    
Is MainViewModel derived from ViewModelBase? If so the binding is being confused by the two MyStaticProperty definitions.

Try making the ViewModelBase MyStaticProperty protected (to hide it from the view) or rename MyStaticProperty (in either class).

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900