Getting Started

Before we go you have to install nuget package for Prometheus.Binding
Then install Prometheus.Binding.RadSupport (coming soon).
Next, we have to initialize the support, by calling Prometheus.Binding.RadSupport.proRadBindingInitializer.Initialize method from App constructor.
That's all.

What is it

Prometheus.Binding does not use attached property mechanism. How binding knows when to update the source value - or, by another word, when the control value changed? - Actually binding does not know by it self, but we can handle some events of the control and do the update. Prometheus.Binding already has built-in handling. It submits to event handling when iniitalizing:
RegisterControlForBindingInitialization<TextBox>((element, isInitializing, binding) =>
                {
                    var textBox = (TextBox) element;
                    if(isInitializing)
                    {
                        textBox.TextChanged += binding.TextBoxOnTextChanged;
                    }
                    else
                    {
                        textBox.TextChanged -= binding.TextBoxOnTextChanged;
                    }
                });
What is done here? When binding (bound to TextBox) is initializing it submits to TextChanged event, which updates the binding:
private  void TextBoxOnTextChanged(object sender, TextChangedEventArgs e)
{
     ToData();
}
So, for every control we use we have to do the same thing.
That is what Telerik.Binding.RadSupport do for some Telerik controls:
proBindingBase.RegisterControlForBindingInitialization<Selector>((element, isInitializing, binding) =>
                {
                    var selector = (Selector) element;
                    if(isInitializing)
                    {
                        selector.SelectionChanged+= SelectorOnSelectionChanged;
                    }
                    else
                    {
                        selector.SelectionChanged -= SelectorOnSelectionChanged;
                    }
                });
For WP7 it also registers default property for some controls. (Because we have to use Prometheus.Binding as attached property in WP7)

Last edited Oct 25, 2012 at 8:43 AM by jinek, version 5

Comments

No comments yet.