Autobinding of elements inside Viewbox does not work

Feb 17, 2011 at 4: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.

Coordinator
Feb 17, 2011 at 4:53 PM

Would you like to recommend a fix? :)

Feb 17, 2011 at 4: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.

 

Coordinator
Feb 17, 2011 at 5:01 PM

It doesn't work in all scenarios...

Coordinator
Feb 17, 2011 at 5:02 PM

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