Silverlight如何获取控件在canvas中的位置!距顶部和距左边的值!
FrameworkElement element = (FrameworkElement)MainCanVas.FindName("控件名字");//MainCanVas为CanVas容器
if (element != null)//此处能找到控件
{
this.TextBox1.Text = "";//这里怎么获取
}
else
{
this.TextBox1.Text = "未找到";
}
[解决办法]
你是要坐标么?
element.GetValue(Canvas.LeftProperty);
element.GetValue(Canvas.TopProperty);
[解决办法]
方案二:
Canvas.GetLeft(element);
Canvas.GetTop(element);