iv'e获得了几个绑定项目控件,这些控件都扮演了放置目标的角色 我需要能够在这些项目控件之间拖放项目。无法在绑定项目控件之间拖放项目
的问题是项目控制的不是由拖放框架
ItemsControl的专家组确认为下降目标:
<ItemsPanelTemplate x:Key="TopPipePanelTemplate">
<StackPanel></StackPanel>
</ItemsPanelTemplate>
的DataTemplate中:
<DataTemplate x:Key="PipeDataItem" >
<Ellipse Width="45" Height="45" Fill="{Binding IsMine,Converter={StaticResource MyCheckerOwnerToColorConverter}}"></Ellipse>
</DataTemplate>
ItemsControl样式:
<Style TargetType="{x:Type ItemsControl}" x:Key="ItemsControlStyle">
<Setter Property="ItemTemplate" Value="{StaticResource PipeDataItem}"></Setter>
<Setter Property="AllowDrop" Value="True"></Setter>
<EventSetter Event="Drop" Handler="ItemsControlDropTarget"></EventSetter>
<EventSetter Event="PreviewMouseLeftButtonDown" Handler="ItemsControl_MouseLeftButtonDown"></EventSetter>
</Style>
**对于该示例可以采取2 ItemsControls的:**
<ItemsControl ItemsSource="{Binding Path=Pipes[23].Checkers}" Style="{StaticResource ItemsControlStyle}"/>
<ItemsControl Grid.Column="1" ItemsSource="{Binding Path=Pipes[22].Checkers}" Style="{StaticResource ItemsControlStyle}"/>
时经常显示:
空(左)一个不为虽然AllowDrop设置为True,并且 处理Drop事件(与所有项目控件一样)在此屏幕上,看ItemsControl的样式上文)
现在时的i颜色它那突然被识别ItemsControl的面板:
<ItemsPanelTemplate x:Key="TopPipePanelTemplate">
<StackPanel Background="AliceBlue"></StackPanel>
</ItemsPanelTemplate>
仿佛现在占据整个细胞,其它占据.. iv'e尝试将面板设置为VerticalAlignment =“Stretch”,但这也没有影响
我试图理解为什么我的itemcontrols不被识别为启用drop, 即使我期望他们占据那个空间,此外,椭圆的项目控制 只被识别,直到椭圆的高度占据它的内容。
什么想法?
只是为了阐明我的意思,认为放置目标是拖动椭圆时,您可以将其放在项目控件的顶部。
现在iv'e刚刚成立的背景为透明
解决方案设置了透明背景,以便堆叠面板延伸以适应整个单元格。 – 2012-03-11 09:30:13