3
我得到了一個ListView像下面這樣。用戶應該選擇一些項目並將drag拖放到其他地方。這不需要按CTRL +點擊哪個是好的。但是在所有選擇完成之後,當我嘗試開始拖動時,左鍵單擊將取消選中被點擊的項目。我怎樣才能使這個行爲像Windows資源管理器,所以選擇不會改變,當我用鼠標開始拖動。我浪費了很多時間,嘗試了一些聲稱的解決方案,比如一個是子類ListView和ListViewItem,並與PreviewMouseLeftButtonDown混淆,但沒有爲我工作。 TIA!ListView開始拖動之前丟失選擇
<ListView SelectionMode="Multiple" Grid.Column="1" >
<ListView.View>
<GridView>
<GridViewColumn Width="25">
<GridViewColumn.CellTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding Path=IsSelected, RelativeSource={RelativeSource FindAncestor, AncestorType=ListViewItem, AncestorLevel=1}}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Width="200" />
</GridView>
</ListView.View>
<ListView.Items>
<ListViewItem>1 - The one and only</ListViewItem>
<ListViewItem>2 - The second and only</ListViewItem>
<ListViewItem>3 - The third and only</ListViewItem>
<ListViewItem>4 - The 4th and only</ListViewItem>
<ListViewItem>5 - The 5th and only</ListViewItem>
<ListViewItem>6 - The 6ht and only</ListViewItem>
</ListView.Items>
</ListView>
確保您的選擇是在觸發MouseUp或Click而不是MouseDown? – jeffora 2010-10-08 04:12:52