Xamarin Forms 2017 Mac : How to created a Backing Field

Hi developers,
i code under Xamarin forms Visual Studio 2017 for Mac.

I would like to created in my program a backing field but I not be able to find the issue alone.
Close my code with the error on mymessage.

My code:

public string myMessage
get {return _mymessage; }
_mymessage = value;

public string myMessage { get; private set; }

public event PropertyChangedEventHandler PropertyChanged;

protected virtual void OnPropertyChanged([CallerMemberName] string PropertyName = null)
    //PropertyChangedEventHandler handler = PropertyChanged;
    PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(PropertyName));
    //if (handler !=null)
    // {
    //    PropertyChanged(this, new PropertyChangedEventArgs(PropertyName));
    // }

By the mouse right click I didn't have the option "Add a backing field" only "spell check /Generate variable "mymessage" /

After severals hours and grey hairs I posted the questions with fully hope

Best Answer


  • TimothyRisiXMTimothyRisiXM USXamarin Team Xamurai
    edited September 2017

    Are you right clicking on the 'myMessage' in

    public string myMessage { get; private set; }

    to try to get a backing field?

    If I add that code to cs file in an XM app and right click on myMessage, under 'Quick Fix' there's an option for "To property with backing field"

    What versions of VSfM and Xamarin.Mac are you using?

  • tjr77tjr77 FRMember ✭✭

    I have the version 7.1(build 1297)

Sign In or Register to comment.