wpf ListBox中子项拖拽的时候对象变化

yulongguiziyao 2014-07-21 06:48:39
如图,我选中的是左边的图形,然后再选中图形的左边向左拖动,经过左边的图形的时候,拖动的就成了左边的图形,为什么啊?
...全文
256 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
yulongguiziyao 2014-08-06
  • 打赏
  • 举报
回复
解决方法:http://blog.csdn.net/yulongguiziyao/article/details/38396739 因为项目中ListBox中的拖动是用的telerik的DragDropManager类来实现的,所以忽略了ListBoxItem样式里的属性,最近看telerik官方网站上的讲解才明白。
exception92 2014-07-22
  • 打赏
  • 举报
回复
你的ItemsPanelTemplate 是用的是Canvas吗?? 在你的ListBoxItem模板中的
<ControlTemplate.Triggers>
设置当IsSelected=true时,设置Panel.ZIndex =1 的触发器。
exception92 2014-07-22
  • 打赏
  • 举报
回复
引用 2 楼 yulongguiziyao 的回复:
[quote=引用 1 楼 duanzi_peng 的回复:] 你的ItemsPanelTemplate 是用的是Canvas吗?? 在你的ListBoxItem模板中的
<ControlTemplate.Triggers>
设置当IsSelected=true时,设置Panel.ZIndex =1 的触发器。
用的是WrapPanel,好像不起作用,是我哪儿写错了吗?[/quote] 你可以在重写 listboxItem的ControlTemplate模板,在它的Triggers属性中设置Panel.ZIndex

<ControlTemplate.Triggers>
                            <Trigger Property="IsSelected" Value="true">
                                <Setter Property="Background" TargetName="Bd" Value="#8DB8C5"/>
                                <Setter Property="Foreground" Value="Black"/>
                                <!--设置Panel.ZIndex,解决在拖拽到与相同listboxItem重合时,当前对象改变错误。-->
                                <Setter Property="Panel.ZIndex" Value="1"></Setter>
                                <!--<Setter Property="IsChecked" Value="True" TargetName="CBSelect"></Setter>-->
                            </Trigger>
</ControlTemplate.Triggers>
测试,因为我用的Canvas
exception92 2014-07-22
  • 打赏
  • 举报
回复
引用 2 楼 yulongguiziyao 的回复:
[quote=引用 1 楼 duanzi_peng 的回复:] 你的ItemsPanelTemplate 是用的是Canvas吗?? 在你的ListBoxItem模板中的
<ControlTemplate.Triggers>
设置当IsSelected=true时,设置Panel.ZIndex =1 的触发器。
用的是WrapPanel,好像不起作用,是我哪儿写错了吗?[/quote] 不是Canvas ,那就不知道了。
yulongguiziyao 2014-07-22
  • 打赏
  • 举报
回复
引用 1 楼 duanzi_peng 的回复:
你的ItemsPanelTemplate 是用的是Canvas吗??
在你的ListBoxItem模板中的
<ControlTemplate.Triggers>

设置当IsSelected=true时,设置Panel.ZIndex =1 的触发器。

用的是WrapPanel,好像不起作用,是我哪儿写错了吗?

8,735

社区成员

发帖
与我相关
我的任务
社区描述
WPF/Silverlight相关讨论
社区管理员
  • WPF/Silverlight社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧