Catel.MVVM.Views.ViewExtensions.EnsureVisualTree C# (CSharp) Method

EnsureVisualTree() public static method

Ensures that a visual tree exists for the view.
public static EnsureVisualTree ( this view ) : void
view this The view.
return void
        public static void EnsureVisualTree(this IView view)
        {
            Argument.IsNotNull("view", view);

#if !XAMARIN
            // According to the documentation, no visual tree is garantueed in the Loaded event of the user control.
            // However, as a solution the documentation says you need to manually call ApplyTemplate, so let's do that.
            // For more info, see http://msdn.microsoft.com/en-us/library/ms596558(vs.95)
            var targetControl = view as Control;
            if (targetControl != null)
            {
                (targetControl).ApplyTemplate();
            }
#endif
        }