0

我正在使用 ListBoxDragDropTarget,当我拖放一个项目时,绑定到 ListBox 的 ObservableCollection 不会更改其项目顺序。

 <controlsToolkit:ListBoxDragDropTarget AllowDrop="True"
                                               Grid.Row="1"
                                               HorizontalContentAlignment="Stretch"             
                                               VerticalAlignment="Top"
                                               Margin="0,10,8,10"
                                               ItemDragCompleted="ListBoxDragDropTarget_ItemDragCompleted_1"
                                               BorderThickness="0">
                  <ListBox x:Name="servicesListBox" ItemsSource="{Binding ServiceCollection}" 
                           ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                           SelectionChanged="servicesListBox_SelectionChanged_1"
                           SelectedItem="{Binding SelectedService, Mode=TwoWay}" 
                           Margin="0,102,0,0" Background="#FF040404"
                           SelectionMode="Extended"
                           Foreground="White" Width="800" HorizontalAlignment="Center" BorderBrush="#FF040404" Height="340" VerticalAlignment="Top" >
                      <ListBox.ItemsPanel>
                          <ItemsPanelTemplate>
                            <controlsToolkit:WrapPanel />
                          </ItemsPanelTemplate>
                      </ListBox.ItemsPanel>
                      <ListBox.ItemTemplate>
                          <DataTemplate>
                            <StackPanel Width="250" Margin="4" Orientation="Horizontal">                                    
                                  <TextBlock Text="{Binding Title}" Foreground="{Binding IsDesactivated, Converter={StaticResource OnlineColorConverter}}"
                                            HorizontalAlignment="Left" VerticalAlignment="Center" Margin="2,0,0,0" Width="190" />
                            </StackPanel>
                          </DataTemplate>
                      </ListBox.ItemTemplate>
                  </ListBox>
            </controlsToolkit:ListBoxDragDropTarget>
4

1 回答 1

0

可能是您在 ObservableCollection 中的项目是异构的。当您使用多态性时会发生这种情况,例如,如果您有一个 ObservableCollection,但它实际上包含 MyClass 类型的元素。这是 ListBoxDragDropTarget 的错误,但此控件在“实验”质量范围内。

两个可能的修复:

于 2012-08-21T12:16:35.070 回答