Reputation: 1086
I am new to WPF and I was wondering if I could draw a line that updated with mouse position purely in XAML?
I know I can do:
...
<Canvas x:Name="MyCanvas">
<Polyline x:Name="MyLine" Points="0,0 1,1" Stroke=1 />
</Canvas>
...
Than in C#
private void MyCanvas_MouseMove(...)
{
if(!DrawFlag)
return;
Point Pos = new Point();
Pos = e.GetPosition(MyCanvas);
MyLine.Points[ MyLine.Points.Count - 1 ] = Pos;
}
Is there a way to have a flag set, DrawFlag, and then have the point position update using only XAML code? I get a feeling the answer may be in creating a Template but not really sure.
Upvotes: 0
Views: 578
Reputation: 1796
It is possible to draw on a canvas purely with XAML using an InkCanvas
<InkCanvas />
Upvotes: 3
Reputation: 292345
No, you can't do that purely in XAML. XAML is a presentation language, not a "real" programming language.
Upvotes: 2