【发布时间】:2013-07-22 09:34:01
【问题描述】:
如何在 C# 中将列表框滚动到底部? ListBox 中的项目没有名称,这可能会使其更加困难。
【问题讨论】:
标签: c# windows-phone-7 listbox windows-phone-8 windows-phone-7.8
如何在 C# 中将列表框滚动到底部? ListBox 中的项目没有名称,这可能会使其更加困难。
【问题讨论】:
标签: c# windows-phone-7 listbox windows-phone-8 windows-phone-7.8
你可以这样做..
listbox.ScrollIntoView(listbox.Items[listbox.Items.Count - 1]);
【讨论】:
在 C# 中:
yourListBox.SelectedIndex = yourListBox.ItemsSource.Count();
如果由于某种原因你没有Count,试试这个:
public static int Count<TSource>(this IEnumerable<TSource> source)
{
if (source == null)
throw new ArgumentNullException("source");
ICollection collection = source as ICollection;
if (collection != null)
return collection.Count;
int num = 0;
foreach (TSource item in source)
checked { ++num; }
return num;
}
【讨论】:
using System.Linq; 添加到文件顶部。
yourListBox.Items.Count吗?