我使用包含 ListBoxItem 樣式的自定義字典創建了一個 ListBox,自定義項包含兩個 ComboBox。但是,當我單擊不在串列頂部的專案的 ComboBox 時,串列會自動滾動,因此打開組合框的專案位于串列頂部。看起來真的很奇怪,所以我想讓它停下來。
我已經將 ListBox 更改為 ListView 并將 Itemtemplate 更改為 ListBoxItem 但它沒有更改任何內容。
我很樂意提供任何建議,謝謝。
uj5u.com熱心網友回復:
您可以使用自定義樣式和RequestBringIntoView-event的事件設定器覆寫此“滾動行為” :
<ListView.ItemContainerStyle>
<Style TargetType="{x:Type ListViewItem}">
<EventSetter Event="RequestBringIntoView" Handler="MyListView_OnRequestBringIntoView"/>
</Style>
</ListView.ItemContainerStyle>
private void MyListView_OnRequestBringIntoView(object sender, RequestBringIntoViewEventArgs e)
{
e.Handled = true;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/384785.html
上一篇:系結轉換器如何將引數傳遞給函式
