Forum Xamarin.Mac

Announcement:

The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

How to update a “label” in ViewController.cs from another C# file in Xamarin MacOS development?

codergcoderg Member ✭✭

I am working on a small MacOS app in Xamarin and using 'Visual Studio for MAC'. I am unable to figure out how to update the value of a label in the ViewController.cs file from another .cs file.

`using System;
using AppKit;
using Foundation;

namespace FramesMac
{

public partial class ViewController : NSViewController
{
    public ViewController(IntPtr handle) : base(handle)
    {
    }

    public override void ViewDidLoad()
    {
        base.ViewDidLoad();
        // Do any additional setup after loading the view.
        lbl_message.StringValue="Processing..."
    }

    public override NSObject RepresentedObject
    {
        get
        {
            return base.RepresentedObject;
        }
        set
        {
            base.RepresentedObject = value;
            // Update the view, if already loaded.
        }
    }

}
}`

I simply want to update lbl_message.StringValue="Processing..." from another .cs file.

Sign In or Register to comment.