本文整理汇总了C#中Windows.UI.Xaml.Controls.ListViewBase.ScrollIntoView方法的典型用法代码示例。如果您正苦于以下问题:C# ListViewBase.ScrollIntoView方法的具体用法?C# ListViewBase.ScrollIntoView怎么用?C# ListViewBase.ScrollIntoView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Windows.UI.Xaml.Controls.ListViewBase
的用法示例。
在下文中一共展示了ListViewBase.ScrollIntoView方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ScrollItem
public static void ScrollItem(ListViewBase control, int indexDelta)
{
if (control == null || control.Items == null)
return;
var scrollViewer = VisualTreeUtilities.GetVisualChild<ScrollViewer>(control);
var p = new Point(Window.Current.Bounds.Width/2, 10);
var transform = control.TransformToVisual(Window.Current.Content);
var checkPoint = transform.TransformPoint(p);
var q = from lvi in VisualTreeHelper.FindElementsInHostCoordinates(checkPoint, scrollViewer).OfType<ListViewItem>()
where lvi.Content != null
select lvi.Content;
var item = q.FirstOrDefault();
if (item == null)
return;
var index = control.Items.IndexOf(item);
var nextItemIndex = index + indexDelta;
if (index != -1 && nextItemIndex >= 0 && nextItemIndex < control.Items.Count)
{
var nextItem = control.Items[nextItemIndex];
control.ScrollIntoView(nextItem, ScrollIntoViewAlignment.Leading);
}
}
示例2: FocusIndex
private static bool FocusIndex(ListViewBase listViewBase, int i)
{
var newContainer = listViewBase.ContainerFromIndex(i) as Control;
if (newContainer == null)
{
return false;
}
newContainer.Focus(FocusState.Keyboard);
listViewBase.ScrollIntoView(newContainer);
return true;
}