我只将AllowDrop设置为叶节点,将AllowDrop = false设置为其他,但设置AllowDrop = false后仍然允许Drop选项。
<TreeView x:Name="tvParameters" >
<TreeView.Resources>
<HierarchicalDataTemplate DataType="{x:Type loc:MyTreeViewItem}" ItemsSource="{Binding SubItems}">
<Grid >
<TextBlock Text="{Binding Path=FullName}" x:Name="tbFullParameter" Visibility="Collapsed"/>
<TextBlock Text="{Binding Path=Name}" AllowDrop="{Binding Path=AllowDrop}" x:Name="tbParameter" PreviewMouseLeftButtonDown="tbParameter_PreviewMouseLeftButtonDown" PreviewMouseMove="tbParameter_PreviewMouseMove"/>
<!--<TextBlock Text="{Binding Name}"/>-->
</Grid>
</HierarchicalDataTemplate>
</TreeView.Resources>
</TreeView>