Пример #1
0
        private static void ValuePropertyDataFunc(Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter)
        {
            var treeView = (Gtk.TreeView)column.TreeView;
            var info     = Templating.GetTemplate(treeView) as TreeViewTemplate;

            var textCell = (cell as Gtk.CellRendererText);

            textCell.Text = string.Empty;
            var value = model.GetValue(iter, 0);

            if (value == null)
            {
                return;
            }

            foreach (var rowTemplate in info.RowTemplates)
            {
                if (value.GetType() == rowTemplate.TargetType)
                {
                    //Here we have a value, which is the source for Binding, and a BindingInfo that is given by rowTemplate.ColumnBindings[column.Title] .
                    //The instance of the BindingInfo is shared among all values (rows), since it was defined once in the rowTemplate.

                    BindingInfo bindingInfo = null;
                    if (!rowTemplate.ColumnBindings.TryGetValue(column.Title, out bindingInfo))
                    {
                        return;
                    }

                    //The actual binding, on the other hand, is specific to the current (row,column) pair.
                    Binding binding   = BindingEngine.GetOrCreateBinding(treeView, value, new TreeViewIterBindingTarget(treeView, iter, column), bindingInfo);
                    var     propValue = binding.GetSourceValue();
                    textCell.Text = propValue == null ? String.Empty : propValue.ToString();
                    return;
                }
            }
        }
Пример #2
0
        public static Binding GetOrCreateBinding(Gtk.Widget widget, Object source, IBindingTarget target, BindingInfo info)
        {
            Binding result = null;

            if (!mBindings.TryGetValue(target, out result))
            {
                result      = new Binding();
                result.Info = info;
                result.Connect(widget, source, target);
                mBindings[target] = result;
            }
            return(result);
        }
Пример #3
0
 public EntryTemplate SetTextBinding(String path)
 {
     mTextBinding = new BindingInfo() { Path = path };
     return this;
 }
Пример #4
0
 public static Binding GetOrCreateBinding(Gtk.Widget widget, Object source, IBindingTarget target, BindingInfo info)
 {
     Binding result = null;
     if (!mBindings.TryGetValue(target, out result)) {
         result = new Binding();
         result.Info = info;
         result.Connect(widget, source, target);
         mBindings[target] = result;
     }
     return result;
 }