Autobinding of elements inside Viewbox does not work

Feb 17, 2011 at 5:40 PM

Somewhere inside class BindingScope is GetNamedElements method which contains the following line,  which does not handle Viewbox control correctly, since its only child is ContainerVisual which is neither UIElement nor UIElement3D.

var childCount = (current is UIElement || current is UIElement3D ? VisualTreeHelper.GetChildrenCount(current) : 0);

This causes the binding of elements inside Viewbox control not to work correctly.

Feb 17, 2011 at 5:53 PM

Would you like to recommend a fix? :)

Feb 17, 2011 at 5:58 PM

Quick fix:

var childCount = (current is UIElement || current is UIElement3D || current is ContainerVisual ? VisualTreeHelper.GetChildrenCount(current) : 0);

but I wonder why not just use VisualTreeHelper.GetChildrenCount(current)  as with version where NET directive is not specified.


Feb 17, 2011 at 6:01 PM

It doesn't work in all scenarios...

Feb 17, 2011 at 6:02 PM

Give me a few minutes to get your fix in :)