Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bind a readonly DependencyProperty to another readonly DependencyProperty

I have a class that contains a readonly DependencyProperty. From this class, I want to bind to the readonly DependencyProperty to another readonly DepenendencyProperty of another class (create binding from code).

Is there a possibility to do this? SetBinding() seems not to have a overload that takes a DependencyPropertyKey as a parameter? Neither seems the BindingOperations-class to provide such functionality.

The question can also be formulated: Can I create a binding for a readonly DependencyProperty if I have the DependencyPropertyKey?

like image 710
HCL Avatar asked Nov 05 '22 15:11

HCL


1 Answers

This isn't possible because the FrameworkElement.SetBinding method only accepts a DependencyProperty as its first parameter. It would have been great if it would also accept a DependencyPropertyKey instead. Because the key isn't visible outside the class, it would still be read-only outside the class, but from within the class you could use it for a binding. Unfortunately, this isn't possible.

like image 76
Ramon de Klein Avatar answered Nov 11 '22 19:11

Ramon de Klein