Having a main window and a canvas class Graphcontext
where animations and several shapes interact like:
xaml
<DockPanel Name="stackPanel2" DockPanel.Dock="Left" Margin="10,10,10,10" LastChildFill="True" >
<myctrl:Graphcontext x:Name="graphSurface" Background="Black" >
</myctrl:Graphcontext>
</DockPanel>
code
public class Graphcontext : Canvas
{
Ellipse _fixedCircle;
internal int CavasWidth { get; set; }
internal int CavasHeight { get; set; }
public void drawSinglePoint(SolidColorBrush color)
{
this.Children.Clear();
_fixedCircle = new Ellipse();
_fixedCircle.Width = 25;
_fixedCircle.Height = 25;
_fixedCircle.Stroke = color;
_fixedCircle.Fill = color;
_fixedCircle.StrokeThickness = 3;
// Get the center x and y coordinates
double x = this.ActualWidth / 2 ;
double y = this.ActualHeight / 2 ;
_fixedCircle.Margin = new Thickness(x, y, 1, 1);
// Add the circle to the canvas
this.Children.Add(_fixedCircle);
this.InvalidateVisual();
}
...
}
I want to clon GraphContext
inside other maximized canvas in second other monitor maybe using Viewbox.
I have tried
Canvas copycanvas = XamlReader.Parse(XamlWriter.Save(graphSurface)) as Canvas;
Viewbox vb = new Viewbox() { StretchDirection = StretchDirection.Both, Stretch=Stretch.Uniform };
vb.Child = copycanvas;
Window newwin = new Window() { Content = vb };
newwin.Show();
However when graphSurface
is updated the copycanvas
is not updated.
I actually see the point, but when I do for instance an animation using a storyboard from codebehind copycanvas
is not updated.
What do I need to do so copycanvas
is always a mirror of graphSurface
?
Do I need to copy all logic into other control?, So that way it always be the same, maybe a little delay...
Maybe databinding canvas to viewbox could do it, but how would it be?