您的位置:首页 > 其它

WPF判断控件的滚动条是否移动到了最底部

2015-04-13 15:40 120 查看
/// <summary>
/// Get a bool value indicate whether is the VerticalScrollBar at buttom
/// </summary>
/// <returns>A bool value indicate whether is the VerticalScrollBar at buttom</returns>
public bool IsVerticalScrollBarAtButtom
{
get
{
bool isAtButtom = false;

// get the vertical scroll position
double dVer = this.VerticalOffset;

//get the vertical size of the scrollable content area
double dViewport = this.ViewportHeight;

//get the vertical size of the visible content area
double dExtent = this.ExtentHeight;

if (dVer != 0)
{
if (dVer + dViewport == dExtent)
{
isAtButtom = true;
}
else
{
isAtButtom = false;
}
}
else
{
isAtButtom = false;
}

if (this.VerticalScrollBarVisibility == ScrollBarVisibility.Disabled
|| this.VerticalScrollBarVisibility == ScrollBarVisibility.Hidden)
{
isAtButtom = true;
}

return isAtButtom;
}
}
转自:/article/1786773.html


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: