TextBlock.GetBindingExpression returns NULL

The following returns NULL for me, any idea why?

MultiBinding collectionRange = new MultiBinding(); collectionRange.Bindings.Add(new Binding("CurrentPosition") { Source = View }); collectionRange.Bindings.Add(new Binding("Count") { Source = View }); collectionRange.StringFormat = "{0} of {1}"; tbFooter.SetBinding(TextBlock.TextProperty, collectionRange); var x = tbFooter.GetBindingExpression(TextBlock.TextProperty); 

MultiBinding is OK - the properties are valid and displayed on the user interface. I just can't capture the binding expression (x is always NULL).

Am I using this method incorrectly?

+6
source share
1 answer

This method is a really handy wrapper around the BindingOperations.GetBindingExpression method. GetBindingExpression passes the current instance and dp parameter to BindingOperations.GetBindingExpression.

If your binding is MultiBinding, use BindingOperations.GetMultiBinding.

See the Notes section and the notes in the Examples section here .

+15
source

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


All Articles