本文整理汇总了C#中System.Windows.Rect.ToXwtRect方法的典型用法代码示例。如果您正苦于以下问题:C# Rect.ToXwtRect方法的具体用法?C# Rect.ToXwtRect怎么用?C# Rect.ToXwtRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Rect
的用法示例。
在下文中一共展示了Rect.ToXwtRect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetCellBounds
public Rectangle GetCellBounds(int row, CellView cell, bool includeMargin)
{
ExListViewItem item = ListView.ItemContainerGenerator.ContainerFromIndex (row) as ExListViewItem;
if (item == null)
return Rectangle.Zero;
// this works only if the wpf layout remains the same
try {
var stackpanel = VisualTreeHelper.GetChild (item, 0);
var border = VisualTreeHelper.GetChild (stackpanel, 0);
var grid = VisualTreeHelper.GetChild (border, 0);
var rowpresenter = VisualTreeHelper.GetChild (grid, 1) as FrameworkElement;
if (VisualTreeHelper.GetChildrenCount (rowpresenter) != view.Columns.Count)
return Rectangle.Zero;
var colpresenter = VisualTreeHelper.GetChild (rowpresenter, cellViews [cell].ColumnIndex) as FrameworkElement;
var colchild = VisualTreeHelper.GetChild (colpresenter, 0) as FrameworkElement;
if (cellViews [cell].Column.Views.Count > 1 && colchild is System.Windows.Controls.StackPanel) {
var childStack = colchild as System.Windows.Controls.StackPanel;
if (childStack == null || VisualTreeHelper.GetChildrenCount (childStack) < cellViews [cell].CellIndex)
return Rectangle.Zero;
var cellpresenter = VisualTreeHelper.GetChild (childStack, cellViews [cell].CellIndex) as FrameworkElement;
var position = cellpresenter.TransformToAncestor (ListView).Transform(new System.Windows.Point(-ListView.Padding.Left, 0));
var rect = new Rect (position, cellpresenter.RenderSize);
return rect.ToXwtRect ();
} else {
var position = colchild.TransformToAncestor (ListView).Transform(new System.Windows.Point(-ListView.Padding.Left, 0));
var rect = new Rect (position, colchild.RenderSize);
return rect.ToXwtRect ();
}
} catch (ArgumentOutOfRangeException) {
return Rectangle.Zero;
} catch (ArgumentNullException) {
return Rectangle.Zero;
}
}