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
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.
Hello Jon,
Do you have any other questions on this matter?
Sincerely,Valerie Developer Support Supervisor - XAMLInfragisticswww.infragistics.com/support
Sorry about the delay. We are releasing our software before I fix the deprecated UnboundField things since we know it currently works. I have looked at the documentation and it will get me going down the correct path. I'll let you know if I have any issues.
Thank you for the update.
Please let me know if you have any questions once you get into your implementation again.
How can I do this in xaml ?
I have the following ...
<dataPresenter:TextField Name="Name"/> //works fine
<dataPresenter:TextField Name="Something.SomethingElse" BindingType="UseAlternateBinding/> //doesn't
My VM looks something like this :
class Thing{
string Name {get;set}
thing Something {get;set;
class Something
string SomethingElse {get;set;}
Michael,
You can use an UnboundField instead of TextField, like this:
<dataPresenter:UnboundField Binding="{Binding Something.SomethingElse}" Label="Something else"/>
I use UnboundField with TwoWay and OneWay modes and BindingPath set (usually to ObjectPath.ObjectProperty). What is an equivalent with AlternateBinding and AlternateBindingRetentionMode as for the performance/ behavior of the old solution? I read that AutoRelease can hit performance when aggregations are performed and Retain will use more memory. That's a question that UnboundField solved for me, because I had no control there :)
Ivan
Well in that case:
<dataPresenter:Field AlternateBinding="{Binding Something.SomethingElse}" BindingType="Unbound" Label="Something else"/>
My understanding was that UnboundField is now deprecated.