我有一个类将Behavior<FrameworkElement>与
protected override void OnAttached()
{
base.OnAttached();
AssociatedObject.AllowDrop = true;
AssociatedObject.DragEnter += AssociatedObject_DragEnter;
AssociatedObject.DragOver += AssociatedObject_DragOver;
AssociatedObject.Drop += AssociatedObject_Drop;
}在xaml中我有
<Border Background="Turquoise">
<Grid Height="800" AllowDrop="True">
<i:Interaction.Behaviors>
<behaviors1:FrameworkElementDropBehavior></behaviors1:FrameworkElementDropBehavior>
</i:Interaction.Behaviors>
...
</Grid>
</Border>我已经在FrameworkElementDropBehavior中定义了Grid,我希望可以在这个Grid上删除相同的对象,因为AssociatedObject应该是整个Grid。但是所发生的事情是,我只允许在网格中有元素定义的部分,例如蓝色、白色或值部分。我确实使用棱镜将整个green Grid注入到TabControl中。知道为什么我只能部分下降吗?

发布于 2014-12-21 13:12:17
例如,只需将Grid的背景属性设置为Transparent。
<Grid Height="800" AllowDrop="True" Background="Transparent">
<i:Interaction.Behaviors>
<behaviors1:FrameworkElementDropBehavior/>
</i:Interaction.Behaviors>
</Grid>这样,就可以在整个网格区域(包括没有子控件的任何空区域)上启用命中测试。
发布于 2014-12-21 13:26:00
我通过将FrameworkElementDropBehavior设置为Border来解决这个问题。
<Border Background="Turquoise">
<i:Interaction.Behaviors>
<behaviors1:FrameworkElementDropBehavior></behaviors1:FrameworkElementDropBehavior>
</i:Interaction.Behaviors>
<Grid Height="800" AllowDrop="True">
...
</Grid>
</Border>https://stackoverflow.com/questions/27589355
复制相似问题