您当前的位置: 首页 > 

君子居易

暂无认证

  • 0浏览

    0关注

    210博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Visual TransformToVisual(Visual)方法

君子居易 发布时间:2020-06-05 14:06:59 ,浏览量:0

返回一个转换,该转换可用于将坐标从Visual转换为指定的视觉对象。

public System.Windows.Media.GeneralTransform TransformToVisual (System.Windows.Media.Visual visual);
一个例子

以下标记示例显示了StackPanel对象中包含的TextBlock。

XAML复制
 

  

下面的代码示例演示如何使用TransformToVisual方法获取其子TextBlock的StackPanel的偏移量。偏移值包含在返回的GeneralTransform值中。

C#复制
 
// Return the general transform for the specified visual object.
GeneralTransform generalTransform1 = myStackPanel.TransformToVisual(myTextBlock);

// Retrieve the point value relative to the child.
Point currentPoint = generalTransform1.Transform(new Point(0, 0));

偏移量考虑所有对象的边距值。在这种情况下,X为-4,Y为-4。偏移值为负,因为父对象相对于其子对象具有负偏移。

注解

使用TransformToAncestor方法和使用TransformToDescendant方法,还可以返回可视对象的转换。

关注
打赏
1660814979
查看更多评论
立即登录/注册

微信扫码登录

0.0355s