Search code examples
c#macosxamarintextboxtextchanged

Xamarin.Mac TextBox Update


I have a form with a TextBox and a Label. My goal is to auto-update the label to the value of the TextBox each time I change something.

I know that in the .NET Framework there is a "TextChange" Event, which worked. But somehow I am not able to recreate this with with Visual Studio for Mac.


Solution

  • Use the Changed event and set the label's StringValue to the text field's StringValue:

    nstextfield.Changed += (sender, e) =>
    {
        label.StringValue = nstextfield.StringValue;
    };