Microsoft.Phone.Controls.ContextMenu.SafeTransformToVisual C# (CSharp) Method

SafeTransformToVisual() private static method

Calls TransformToVisual on the specified element for the specified visual, suppressing the ArgumentException that can occur in some cases.
private static SafeTransformToVisual ( UIElement element, UIElement visual ) : System.Windows.Media.GeneralTransform
element UIElement Element on which to call TransformToVisual.
visual UIElement Visual to pass to the call to TransformToVisual.
return System.Windows.Media.GeneralTransform
        private static GeneralTransform SafeTransformToVisual(UIElement element, UIElement visual)
        {
            GeneralTransform result;
            try
            {
                result = element.TransformToVisual(visual);
            }
            catch (ArgumentException)
            {
                // Not perfect, but better than throwing an exception
                result = new TranslateTransform();
            }
            return result;
        }