所以我通过在每次为矩形点击区域和面板调用 MouseEnter 和 MouseLeave 时检查 IsMouseOver 属性来解决它。
private bool isMouseOverRightPanelOrHitRect()
{
if (mRightPanel.IsMouseOver || rightHitRect.IsMouseOver)
return true;
return false;
}
private void handleRightPanelAnimation(object sender, MouseEventArgs e)
{
if (isMouseOverRightPanelOrHitRect())
mRightPanel_FlyOn();
else
mRightPanel_FlyOff();
}
private void mRightPanel_FlyOn()
{
if (!mRightPanel.Docked)
VisualStateManager.GoToElementState(mCanvas, rightOn.Name, true);
}
private void mRightPanel_FlyOff()
{
if (!mRightPanel.Docked)
VisualStateManager.GoToElementState(mCanvas, rightOff.Name, true);
}