1
我想在windows phone 7.1中捕獲一個簽名。剪輯InkPresenter到繪圖區域
我可以在屏幕上繪圖,但我無法將繪圖區域限制爲InkPresenter控件,除非在mousemove事件中添加了一些處理。
如何限制使用XAML繪圖區域或者這是不可能的?
XAML代碼
<InkPresenter Name="inkTest" Background="White" MinHeight="180" MinWidth="250" />
代碼隱藏
private Stroke _currentStroke;
private void inkTest_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
_currentStroke = null;
}
private void inkTest_MouseMove(object sender, MouseEventArgs e)
{
if (_currentStroke == null) return;
//HACK: want to set this in XAML
var position = e.GetPosition(inkTest);
if (position.X <= inkTest.ActualWidth &&
position.Y <= inkTest.ActualHeight)
_currentStroke.StylusPoints.Add(GetStylusPoint(position));
}
private void inkTest_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
inkTest.CaptureMouse();
_currentStroke = new Stroke();
_currentStroke.StylusPoints.Add(GetStylusPoint(e.GetPosition(inkTest)));
_currentStroke.DrawingAttributes.Color = Colors.Blue;
inkTest.Strokes.Add(_currentStroke);
}
private StylusPoint GetStylusPoint(Point position)
{
return new StylusPoint(position.X, position.Y);
}
不客氣:) – keyboardP