Question

OK, from the "I never expected THIS to be the hard part" department: how do I set the text of a NSTextField in Xamarin Mac?

  NSTextView view = new NSTextView(new RectangleF(0, 500, 200, 40));
  view.StringValue = "Foo";

does not compile (no method "StringValue"). Nor does SetStringValue("Foo"). Nor does there appear to be any SetText method. There's an InsertText method, but it doesn't take a C# string; it wants an NSObject (which makes me think it's not really intended for direct use).

Note that if I use NSTextField instead of NSTextView, I can assign to StringValue just fine. But with NSTextField, the same code fails.

I'm experienced in ObjC programming on iOS, but pretty much a noob to both Mac Cocoa and Xamarin Mac. So I'm sure I'm missing some obvious answer, but my googling hasn't found an answer (and the Xamarin forums are down today). Any help will be greatly appreciated.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top