在WPF中将图片从一个画布移动到另一个画布 [英] Move Picture from one Canvas to another Canvas in WPF

查看:313
本文介绍了在WPF中将图片从一个画布移动到另一个画布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何将图片从一个画布移动到另一画布.如果我单击画布1中的图像,则单击相同的图像后又出现在画布2中,并且该图像也从画布1中消失了.

How i can move a picture from one canvas to another canvas. If i click on image that is in canvas 1 then after clicking same image appeared in canvas 2 & also disappeared that image from canvas 1

推荐答案

我从没尝试过,但是做了很多根据其他控件或框架元素的经验,确定它会起作用.

一个对象将从一个父对象(Canvas或其他任何从System.Windows.Media.Visual派生的其他类)跳转"到另一个对象,您在一个老"父对象上调用RemoveVisualChildRemoveLogicalChild,然后调用AddLogicalChildAddVisualChild和另一个具有相同子对象的新"父对象.

—SA
I never tried but pretty much sure it will work, based on experience with other controls or framework elements.

An object will "jump" from one parent (Canvas or any other other class derived from System.Windows.Media.Visual) to another it you call RemoveVisualChild and RemoveLogicalChild on one "old" parent and then call AddLogicalChild and AddVisualChild and another, "new" parent with the same child object.

—SA


这篇关于在WPF中将图片从一个画布移动到另一个画布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆