I have inherited a legacy project that uses WPF. We make use of Infragistics.
Below is a made-up class structure:
public class DogsVM
{
public string ViewName { get; set; } = "My Dogs";
public List<Dog> Dogs { get; set; }
}
public class Dog
{
public string DogName { get; set; }
public string Description { get; set; }
}
I am using a XamDataGrid to display my data.
Currently the DataSource on the XamDataGrid is DataSource="{Binding CollectionView}".
When I output the field I am using the following
<igDP:Field Name="DogName " Label="Dog Name" AllowEdit="False" />
I want the change the Label to be from DogsVM and select the field ViewName
If I do
<igDP:Field Name="DogName " Label="{Binding ViewName}" AllowEdit="False" />
DogName is outputted as I am looking at a Dog object, not a DogsVM object. How can I get to the parent object in the label binding?
On the Infragistics site there is the following explanation for a similar problem:
So, on the Infragistics site is recommended to use
FieldBindingmarkup extension in order to bind properties to theField,FieldSettings, orFieldLayoutSettings.While mentioned post includes example that uses the MVVM pattern the
FieldBindingmarkup extension can be used without it.Related to the question above consider to set the
DataContextin the constructor:Now set
DataSourcefor theXamDataGridand use theFieldBindingmarkup extension:See similar: https://stackoverflow.com/a/64545966/6630084