[Gtk-sharp-list] Strategy for Databinding Entry to Business Object Property

jaboo rbrinson at gmail.com
Mon Jun 23 19:27:09 EDT 2008


I have a little C#/GTK# project that I have been working on that is
presenting an interesting challenge to me. I have a traditional 3-tier
architecture with GTK# presenting the UI, a pure C# problem domain (business
layer), and a disk IO layer for the data access layer, since the app works
with JPG photos on the file system. The main business class is Picture, and
it has some properties that are displayed/edited at the UI level in
Gtk.Entry and Gtk.TextView objects.

Thus far, I have been managing the edit of these Entry/TextView objects by
capturing the existing Text value in the OnFocusInEvent and then comparing
that captured string to the Text property of the Entry/TextView object in
the OnFocusOutEvent. If they are not equal, then obviously a change was
made, and I update the Picture objects property.

Today, I recognized a problem with this strategy in that if the user clicks
on the Gtk.MenuBar or the Gtk.Toolbar, the OnFocusOutEvent is not triggered.
Thus updating the property on Picture does not occur, and the user may be
clicking on the Save toolbar button or Save menu item.

The only other property update strategy that I have been able to think of is
to use the OnChanged event of the Entry/TextView.Buffer object. However,
this event is fired everytime a character is typed or deleted. This seems
like it would be firing off way too many events.

The System.Windows.Forms.TextBox has a DataBindings property that can be
used to set the datasource for a TextBox. Does anything like this exist for
GTK#? Does anyone have another databinding strategy that they could suggest
or point to with a URL? Thanks for any insights.
-- 
View this message in context: http://www.nabble.com/Strategy-for-Databinding-Entry-to-Business-Object-Property-tp18080605p18080605.html
Sent from the Mono - Gtk# mailing list archive at Nabble.com.



More information about the Gtk-sharp-list mailing list