MahApps/MahApps.Metro — pull request #984 by remcoros (2014-01-28 11:31:46+00:00)
Title: Fix for finding real Flyout visual control when using MVVM

MetroWindow and InternalCleanWindowGlueBehavior handle the FlyoutsControl.Items collection wrong.

In an MVVM scenario, the Items collection does not contain the actual Flyout control, but the viewmodel object.

I changed it to use a 'FindVisualChildren' helper to obtain the real Flyout control.

Note that I couldn't use the existing FindChildren extension method, because that one uses the logical tree, resulting in nothing found at all.

This is a show stopper bug, as in an MVVM scenario a 'Cast exception' was thrown on casting the Items collection to Flyout.