Question

I am attempting to build an application that will show different columns in the same XamDataGrid for different Projects. Here is an example:

public class Project
{
  public ICollection<Person> People { get; private set; }
  public string DisplaySpec { get; private set; }
}

public class Person{
{
  public Name Name { get; set; }
}

public class Name
{
  ... a bunch of dynamic properties that vary by project...
}

I can look up the properties for each Name dynamically with no problem, and if I write Xaml and compile it in the actual executable I can display them. But each project has a different list of fields to bind to, and I want them to be able to inject the field names to display.

Is there any easy manner in which I can allow them to specify the name of the fields that they want to use?

Was it helpful?

Solution

The fields themselves can't be bound. Your best options are to either to auto generate the fields or to have a method in code that would add the fields needed dynamically. If you are looking to have a solution that you can use a binding in XAML with you could put the logic to add the fields into a behavior on the grid that exposes a property that you could bind your list to.

To auto generate the fields you would need to set the AutoGenerateFields on the FieldLayoutSettings to True.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top