1

Is it possible to dynamically get the binding properties for a view into a class and manipulate it in run time. for example, if the DataContext is of type User that has 10 properties, but the bound properties are only 4, can I make a class that has these 4 properties only?

mshwf
  • 7,009
  • 12
  • 59
  • 133

1 Answers1

0

Doable, but difficult.

  1. You must parse the visual tree, and visit every control using VisualTreeHelper (see: https://stackoverflow.com/a/874426/275330).
  2. For every control you can get a list of its dependency properties (see https://stackoverflow.com/a/26367132/275330)
  3. Then for each separate dependency property you can check if its value is set locally (see: Knowing if a DependencyProperty has not been set in XAML). If so - you have the value you need.

I've never used 1+2+3 together, so I don't know what additional difficulties you may have.

Maciek Świszczowski
  • 1,155
  • 11
  • 28