Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

Hi all.

Well this is odd question but here it comes

Is it possible to represent preview about usercontrol without presenting and loaded it on the wpf form as a usercontrol?

in code something like this

in xaml we have preview image component
<Image x:Name="previewImage"></Image>


and somewhere in codebehind

MyUserControl control = new MyUserControl();
//get here image of control and present it as a Source of previewImage component
previewImage.Source = "Here is preview about my usercontrol"


Received image should be handled in runtime memory and not to be saved in hard drive.

Hope you got idea :)

Cheers!
Posted
Updated 7-Dec-11 18:32pm
v2
Comments
Al Moje 8-Dec-11 0:33am    
Replace bossible with possible.

1 solution

You can use a VisualBrush for that purpose.


You can add a Rectangle (instead of your Image):


XML
<Rectangle Name="myRect" Stroke="Black" StrokeThickness="2" Margin="5" />

and, set its Fill with a VisualBrush that contains your control:


C#
MyUserControl control = new MyUserControl();

VisualBrush vb = new VisualBrush
{
    Visual = control,
    Stretch = System.Windows.Media.Stretch.Uniform
};

myRect.Fill = vb;

 
Share this answer
 
Comments
paleGegg0 8-Dec-11 3:19am    
Absolutely brilliant, saved my day :)!

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