简体   繁体   中英

Can all of a UIElement RenderTransform effected properties be copied into a new Element?

I want to make a copy of the Element that has the new properties based upon the RenderTransform. For example, a ScaleTransform of an element on one canvas to another canvas.

private void CopyElement(UIElement elem, Canvas src, Canvas dest, Size scale, Vector offset) {
    ScaleTransform resize = new ScaleTransform(scale.Width, scale.Height);
    elem.LayoutTransform = resize;
    UIElement newElem = CopyElement(src, elem); 
    Canvas.SetLeft(newElem, Canvas.GetLeft(elem) * scale.Width + offSet.X);
    Canvas.SetTop(newElem, Canvas.GetTop(elem) * scale.Height + offSet.Y);
    dest.Children.Add(newElem);
}

You don't need to do this at all.

Just set the element's LayoutTransform property instead of its RenderTransform .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM