Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
In C#, using WPF components, Is it possible to display a canvas (whose contents change at run time based on user input) at two positions on the screen? or in two windows? So basically, whatever happens in the canvas positioned at one place happens in the canvas positioned in the other place.
Posted
Comments
Sergey Alexandrovich Kryukov 18-May-12 11:02am    
Why won't you just try it? I would expect it failed. I know for sure that an attempt to make a reference to UIElement a child of two different instances of canvas throws exception; I would expect same thing for a single reference of a canvas added to two different parents. WPF tracks such things.
A weird request though. If you have only one canvas, why showing it in two different places? It would be confusing to say the least. I bet you can device better design.
--SA
[no name] 18-May-12 14:41pm    
well it can't be contained by 2 paretns, but you might want to render same thing 2 times (like the windows 7 preview for example :) )
Sergey Alexandrovich Kryukov 28-May-12 19:16pm    
Yes, I understand these two things are different. And yes, if you have the same picture rendered in different scale, or different pan, etc., it would make sense, I would agree.
Thank you for this important note.
--SA

1 solution

You can use a VisualBrush, for that purpose.


You can add a Rectangle and, set its Fill with a VisualBrush that contains your Canvas as its Visual.

 
Share this answer
 
Comments
fct2004 19-May-12 14:59pm    
This sounds like it might have a chance of working. I know you can't place the actual Canvas at multiple locations at once, because the visual tree will only allow it to have one parent. Yet, two images (not Images) of the Canvas and its contents, sounds like it might work. You might have a bit of trouble interacting with it on a GUI level.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900