ListViewBase.SingleSelectionFollowsFocus 屬性

定義

取得或設定值,這個值表示當鍵盤焦點變更時,專案選取專案是否會變更。

public:
 property bool SingleSelectionFollowsFocus { bool get(); void set(bool value); };
bool SingleSelectionFollowsFocus();

void SingleSelectionFollowsFocus(bool value);
public bool SingleSelectionFollowsFocus { get; set; }
var boolean = listViewBase.singleSelectionFollowsFocus;
listViewBase.singleSelectionFollowsFocus = boolean;
Public Property SingleSelectionFollowsFocus As Boolean
<listViewBase SingleSelectionFollowsFocus="bool" />

屬性值

Boolean

bool

如果鍵盤焦點變更時專案選取專案變更,則為true;否則為false。 預設值為 True

Windows 需求

裝置系列
Windows 10 Anniversary Edition (已於 10.0.14393.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v3.0 引進)

備註

如果清單檢視的 SelectionMode 屬性未設定為 Single,則會忽略這個屬性。

根據預設,當清單檢視設定為單一選取專案時,當使用者將鍵盤焦點移至專案時,也會選取焦點專案。 例如,如果鍵盤焦點從第一個專案移至第二個專案, SelectedIndex 屬性就會從 0 更新為 1。

將此屬性設定為 false ,讓使用者移動焦點,而不需選取下列專案。 例如,如果每個選取專案變更造成重要的 UI 更新,您可能會偏好讓使用者將焦點移至非連續的專案,然後按 Enter 鍵來更新選取專案。

版本相容性

在 Windows 10 1607 版之前,無法使用 SingleSelectionFollowsFocus 屬性。 如果您的 App 在 Microsoft Visual Studio 中的「最低平臺版本」設定小於此頁面稍後的 [需求] 區塊中顯示的「引進版本」,您必須設計並測試您的應用程式以考慮此設定。 如需詳細資訊,請參閱 版本調適型程式碼

若要避免在舊版Windows 10上執行應用程式時發生例外狀況,請勿在 XAML 中設定此屬性,或在不執行執行時間檢查的情況下使用它。 此範例示範如何使用 ApiInformation 類別,在設定此屬性之前檢查此屬性是否存在。

<ListView x:Name="listView1" Loaded="ListView_Loaded"/>
private void ListView_Loaded(object sender, RoutedEventArgs e)
{
    if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.Controls.ListViewBase", "SingleSelectionFollowsFocus"))
    {
        listView1.SingleSelectionFollowsFocus = false;
    }
}

適用於