本文整理汇总了C#中TreeViewItem.TransformToVisual方法的典型用法代码示例。如果您正苦于以下问题:C# TreeViewItem.TransformToVisual方法的具体用法?C# TreeViewItem.TransformToVisual怎么用?C# TreeViewItem.TransformToVisual使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TreeViewItem
的用法示例。
在下文中一共展示了TreeViewItem.TransformToVisual方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsOnCurrentPage
/// <summary>
/// Determines whether the treeviewitem is on current page.
/// </summary>
/// <param name="treeViewItem">The tree view item.</param>
/// <param name="itemsHostRect">The items host rect.</param>
/// <param name="treeViewItemRect">The tree view item rect.</param>
/// <returns>
/// <c>true</c> if the treeview is on current page otherwise, <c>false</c>.
/// </returns>
private bool IsOnCurrentPage(TreeViewItem treeViewItem, out Rect itemsHostRect, out Rect treeViewItemRect)
{
// Get Rect for item host element
FrameworkElement itemsHost = this.elementScrollViewer;
itemsHostRect = new Rect(new Point(), new Point(itemsHost.RenderSize.Width, itemsHost.RenderSize.Height));
// Adjust Rect to account for padding
Control itemsHostControl = itemsHost as Control;
if (null != itemsHostControl)
{
Thickness padding = itemsHostControl.Padding;
itemsHostRect = new Rect(
itemsHostRect.Left + padding.Left,
itemsHostRect.Top + padding.Top,
Math.Max(0, itemsHostRect.Width - padding.Left - padding.Right),
Math.Max(0, itemsHostRect.Height - padding.Top - padding.Bottom));
}
// Get relative Rect for ListBoxItem
GeneralTransform generalTransform = treeViewItem.TransformToVisual(itemsHost);
treeViewItemRect = new Rect(generalTransform.Transform(new Point()), generalTransform.Transform(new Point(treeViewItem.RenderSize.Width, treeViewItem.RenderSize.Height)));
// Return result
return ((itemsHostRect.Top <= treeViewItemRect.Top) && (treeViewItemRect.Bottom <= itemsHostRect.Bottom));
}