語言

ListBox.ScrollIntoView(Object) 方法

定義

會讓該物體捲入畫面。

public:
 void ScrollIntoView(System::Object ^ item);
public void ScrollIntoView(object item);
member this.ScrollIntoView : obj -> unit
Public Sub ScrollIntoView (item As Object)

參數

item
Object

物件可捲動。

範例

以下範例說明如何使用 ScrollIntoView 此方法將清單框中的項目捲動到視窗中。

private void ScrollIntoView(object sender, RoutedEventArgs e)
{
    var index = cbScrollIntoView.SelectedIndex;
    var item = lbScrollIntoView.Items.GetItemAt(index);
    lbScrollIntoView.ScrollIntoView(item);
}
Private Sub ScrollIntoView(ByVal sender As Object, ByVal e As RoutedEventArgs)
    Dim index = cbScrollIntoView.SelectedIndex
    Dim item = lbScrollIntoView.Items.GetItemAt(index)
    lbScrollIntoView.ScrollIntoView(item)
End Sub

備註

如果物件不可見,則會將其對齊在視窗的頂部或底部。

適用於