WPF binding to non dependency property on control pattern

I am creating a custom WPF control as an automatic learning exercise. My control has a ListView inside the template. I want my managing user to be able to define the necessary columns in their own Xaml, but I did not get a strategy on how to pass the columns to the internal list, because the binding to FindAncestor complains that the "Columns" are not DependencyProperty. Wake, questions:

  • How to achieve property binding from xaml to a template when it is not DP
  • Correct my design: I think something is wrong: if someone completely changes my template, how can I let him use the Column collection?
+3
source share
2 answers

why not inherit from ListView directly? Then you have all the properties necessary for the ListView, and you can also add your own properties to your class.

Then you can apply your own style to your control so that it looks the way you want it to. ( Here you have a basic ListView style that you can use and extend for your needs)

+3
source

Sometimes binding to a property that is not a dependency property can be resolved using OneWayToSource Binding Mode

Have you tried this?

+3
source

Source: https://habr.com/ru/post/1796237/


All Articles