2013-02-04 32 views
0

我有一個列表框,誰的itemsource綁定到SelectionMode =「Single」的列表。我的列表框也有一個ItemContainerStyle爲它設置如下:刪除後不能從列表框中選擇相同的項目

<ListView.ItemContainerStyle> 
    <Style TargetType="{x:Type ListViewItem}"> 
     <Style.Resources> 
      <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent" /> 
      <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent" /> 
     </Style.Resources> 
     <Style.Triggers> 
      <Trigger Property="IsMouseOver" Value="True"> 
       <Setter Property="Background" Value="Blue" /> 
      </Trigger> 
     </Style.Triggers> 
    </Style> 
</ListView.ItemContainerStyle> 

當我刪除列表中的一個項目,我不能,除非我選擇不同的項目重新選擇項目,然後回去吧。任何人都可以對此提出意見嗎?

回答

0

根據您如何從列表中刪除項目,ListView可能會在刪除後失去焦點,這可能會影響SelectedItemHighlight Color。該項目實際上是Selected,但似乎不是用戶,因爲ListView不是活動控件。例如,如果您單擊表單上其他位置的某個按鈕以刪除ListView中的項目,則可能會發生這種情況。

嘗試在刪除操作後在ListView實例上調用Focus()

+0

我會怎麼做,使用MVVM? – user1884032

+0

您可以發佈一些代碼,瞭解您當前如何從列表中移除項目?如果我看到您目前的實施情況,我將能夠幫助您。 – Mash

相關問題