Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2370
Unbound Field in 14.2
posted

In the recent update to 14.2, there are now some compiler warnings about UnboundField being deprecated.  It says to 'Use Field with BindingType set to Unbound or UseAlternateBinding instead".

I have tried both without success.  

My original code had bindings set up like this:

Field field = new UnboundField { BindingMode = BindingMode.TwoWay, BindingPath = new PropertyPath(MyPropertyName) };

What is the new syntax for how my old code works?

From what I see in the compiler warnings, this should be the equivalent:

Field field = new Field { BindingType = BindingType.UseAlternateBinding, AlternateBinding = new Binding(MyPropertyName) };

But it does not function properly.

Thanks,

Jon

Parents
No Data
Reply
  • 12875
    Verified Answer
    posted

    Hi Jon, 

    Let me first recommend that you review this documentation.

    http://help.infragistics.com/Help/Doc/WPF/2014.2/CLR4.0/html/xamDataPresenter_Add_Unbound_Fields_to_a_DataPresenter_Control.html 

    If you want to create the equivalent of an unbound field you can set a field's BindingType to Unbound.

    Field fldUnbound = new Field

    {

       Name = "FLD_Name",

       Label = "Unbound FLD_Name Field",

       BindingType = BindingType.Unbound

    }; 

    You would now need to provide the value for FLD_Name in the InitializeRecord

    Perhaps assigning a value based on other fields, as in the example in the documentation.

    if (e.Record is DataRecord)

    {

          var dr = (DataRecord)e.Record;

          dr.Cells["FLD_Name "].Value = "This field is unbound";

    Or if you want to use the alternate binding method  (ID is a property in my collection object)

    This binds the field to the value in ID.

    Field field = new Field {

        Label="UseAlternateBinding ID",

        BindingType = BindingType.UseAlternateBinding,

        AlternateBinding = new Binding("ID")

    }; 

    The default BindingType is UseNameBinding, which, as you would expect, is binding to the Named property value in your data. 

    Let me know if you have any questions.

Children