[MonoDevelop] Public Widgets using Stetic?

Adam Tauno Williams awilliam at whitemice.org
Mon Mar 16 06:39:32 EDT 2009

On Fri, 2009-03-13 at 18:07 -0700, danieru wrote:
> I'm a little unclear on how to interact with the code that stetic generates.
> For testing purposes,

It is entirely automatic (partial classes).  You don't have to "do"

>  I have a separate thread that's trying to update text
> on 'label1' in my GUI, like so:
> Gtk.Application.Invoke(delegate{ win.Title = updateVal; });
> With 'win' being an instance of the 'MainWindow' class that Monodevelop
> gives you for a gtk project. Inside 'MainWindow' I have:
> public string Title {
> 		get { return label1.Text; }
> 		set { label1.Text = value; }
> 	}
> ..but running gives me a 'NullReferenceException' on the set line in the
> property.  It's acting as if it can't see the label1 object. so, two
> questions:
> 1. What am I missing here to access the label?

Did you mess with the default constructor?  It should start with
this.Build(); which calls a method provided in the Stetic portion of the
partial class.  This is provided when you create a new widget objects.

> 2. Once I have this figured out, I'll be accessing a NodeView to update it.
> What is the best way to update a NodeView?  


> Michael Hutchinson wrote: 
> > In general in .NET/Mono it is recommended to use properties instead of
> > public/protected fields, as this allows you to change internal
> > implementation without breaking ABI.  Trivial properties are inlined
> > by the JIT so there is no real cost. The commonness of trivial
> > properties with backing fields is why we have automatic properties in
> > C# 3.
> > public string Title {
> >     get { return titleLabel.Text; }
> >     set { titleLabel.Text = value; }
> > }
> > 
OpenGroupware developer: awilliam at whitemice.org
OpenGroupare & Cyrus IMAPd documenation @

More information about the Monodevelop-list mailing list