Example #1
0
        /// <summary> 
        /// NOTE: THIS METHOD IS ONLY FOR INTERNAL SPECIFIC USE. It does not support some features of FrameworkElement,
        /// for example RenderTarnsfromOrigin and LayoutTransform. 
        /// 
        /// This is the method layout parent uses to set a location of the child
        /// relative to parent's visual as a result of layout. Typically, this is called 
        /// by the parent inside of its ArrangeOverride implementation. The transform passed into
        /// this method does not get combined with offset that is set by SetLayoutOffset, but rahter resets
        /// LayoutOffset to (0,0). Typically, layout parents use offset most of the time and only need to use this method instead if they need to introduce
        /// a non-trivial transform (including rotation or scale) between them and a layout child. 
        /// DO NOT name this SetLayoutTransform()!  The Xaml Compile may be fooled into thinking LayoutTransform is an attached property.
        /// </summary> 
        /// <param name="element">The element on which to set a transform.</param> 
        /// <param name="layoutTransform">The final transform of this element relative to its parent's visual.</param>
        internal static void InternalSetLayoutTransform(UIElement element, Transform layoutTransform) 
        {
            FrameworkElement fe = element as FrameworkElement;
            element.InternalSetOffsetWorkaround(new Vector());
 
            Transform additionalTransform = (fe == null ? null : fe.GetFlowDirectionTransform()); //rtl
 
            Transform renderTransform = element.RenderTransform; 
            if(renderTransform == Transform.Identity)
                renderTransform = null; 

            // Create a TransformCollection and make sure it does not participate
            // in the InheritanceContext treeness because it is internal operation only.
            TransformCollection ts = new TransformCollection(); 
            ts.CanBeInheritanceContext = false;
 
            if(additionalTransform != null) 
                ts.Add(additionalTransform);
 
            if(renderTransform != null)
                ts.Add(renderTransform);

            ts.Add(layoutTransform); 

            TransformGroup group = new TransformGroup(); 
            group.Children = ts; 

            element.InternalSetTransformWorkaround(group); 
        }
Example #2
0
 internal static void InternalSetLayoutTransform(UIElement element, Transform layoutTransform)
 {
     FrameworkElement frameworkElement = element as FrameworkElement;
       element.InternalSetOffsetWorkaround(new Vector());
       Transform transform1 = frameworkElement == null ? (Transform) null : frameworkElement.GetFlowDirectionTransform();
       Transform transform2 = element.RenderTransform;
       if (transform2 == Transform.Identity)
     transform2 = (Transform) null;
       TransformCollection transformCollection = new TransformCollection();
       transformCollection.CanBeInheritanceContext = false;
       if (transform1 != null)
     transformCollection.Add(transform1);
       if (transform2 != null)
     transformCollection.Add(transform2);
       transformCollection.Add(layoutTransform);
       element.InternalSetTransformWorkaround((Transform) new TransformGroup()
       {
     Children = transformCollection
       });
 }