0
我有一個使用UserControl作爲項目模板的列表框。在UserControl內部,我有一個圖像(X),單擊它時,發出事件以從列表框中刪除UserControl(listitem)。帶自定義Listitem的列表框 - 防止選擇?
有沒有一種方法可以防止列表框在用戶點擊圖片時選擇該項目,但是仍然允許listitem選擇控件中的所有內容?
我有一個使用UserControl作爲項目模板的列表框。在UserControl內部,我有一個圖像(X),單擊它時,發出事件以從列表框中刪除UserControl(listitem)。帶自定義Listitem的列表框 - 防止選擇?
有沒有一種方法可以防止列表框在用戶點擊圖片時選擇該項目,但是仍然允許listitem選擇控件中的所有內容?
確保您標記的事件,當用戶點擊Image
作爲處理:
private void ImageClicked(object sender, RoutedEventArgs e)
{
//send out event to remove UserControl
//ensure the event doesn't bubble up further to the ListBoxItem
e.Handled = true;
}
我做的,但我處理「點擊」 OnMouseButtonUp,顯然列表框中選擇處理OnMouseButtonDown。我試過使用HitTest框架,但迄今沒有運氣。 – Bill 2009-09-18 14:47:40
處理MouseLeftButtonDown事件並修復!我現在感到很傻,=) – Bill 2009-09-18 15:46:44