更改光标是通过this.Cursor
属性完成的。
我打开了文章中的代码,看看他们是怎么做的……
如果未OnMouseMove
单击鼠标左键,则光标会更改:
Point currentLocation = e.MouseDevice.GetPosition(wnd);
......
......
const int dragHandleWidth = 3;
var bottomHandle = new Rect(0, height - dragHandleWidth, width, dragHandleWidth);
var rightHandle = new Rect(width - dragHandleWidth, 0, dragHandleWidth, height);
Point relativeLocation = wnd.TranslatePoint(currentLocation, this);
if (rightHandle.Contains(relativeLocation))
{
this.Cursor = Cursors.SizeWE;
}
else if (bottomHandle.Contains(relativeLocation))
{
this.Cursor = Cursors.SizeNS;
}
else
{
this.Cursor = Cursors.Hand;
}
换句话说,他们检查当前鼠标位置是否在底部或右边框的 3 px 内,如果是,他们会相应地更改光标...
您可以轻松更改此逻辑以满足您的需求....