WPF DataTemplate Binding奇怪的问题

zhujinqi2010 2010-09-21 01:42:46
大家好
我在DataTemplate中定义了一个Buton,然后给Button的Command调用一个路由命令,这样这个路由命令始终不会触发
但是我在DataTemplate外面定义一个Buton,同样的方式调用那个路由命令就可以了
不知道这是为什么!
...全文
317 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
emeraldpiggy 2011-06-06
  • 打赏
  • 举报
回复
this is because
<ItemsControl Background="DarkCyan" ItemsSource="{Binding Path=Nodes }">
you already bind an object, I guess

<Button Width="28" Height="18"
Command="thriple:ContentControl3D.RotateCommand"
CommandTarget="{Binding ElementName=Ctrl3D2}">
</Button>

the binding target is not included in Nodes
zhujinqi2010 2010-09-23
  • 打赏
  • 举报
回复
大家快来帮我顶顶啊,不能就这样沉了
fangxiaofelix 2010-09-21
  • 打赏
  • 举报
回复
WPF还在我的学习计划中,现在只能帮忙顶了!
loveheye 2010-09-21
  • 打赏
  • 举报
回复
只能帮你顶顶~
loveheye 2010-09-21
  • 打赏
  • 举报
回复
只能帮你顶顶~
zhujinqi2010 2010-09-21
  • 打赏
  • 举报
回复
不好意思,格式怎么都变掉了,不好看了,麻烦大家仔细看一下
zhujinqi2010 2010-09-21
  • 打赏
  • 举报
回复
<DockPanel>
<Canvas>
<thriple:ContentControl3D x:Name="Ctrl3D1">
</thriple:ContentControl3D>
<!--这里调用thriple:ContentControl3D.RotateCommand是可以触发的-->
<Button Command="thriple:ContentControl3D.RotateCommand"
CommandTarget="{Binding ElementName=Ctrl3D1}"
</Button>

</Canvas>


<local:NodeCoorator x:Name="NodeContor1" Graph="{Binding Path=.}">
<ItemsControl Background="DarkCyan" ItemsSource="{Binding Path=Nodes }">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<jas:DragCanvas/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>


<ItemsControl.ItemTemplate>
<DataTemplate>
<Border Width="30" Height="40">

<thriple:ContentControl3D x:Name="Ctrl3D2">
</thriple:ContentControl3D>

<!--这里调用thriple:ContentControl3D.RotateCommand就不能触发的-->
<Button Width="28" Height="18"
Command="thriple:ContentControl3D.RotateCommand"
CommandTarget="{Binding ElementName=Ctrl3D2}">
</Button>

</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>

</ItemsControl>
</local:NodeConnectionAdornerDecorator>
</DockPanel>
leon0905 2010-09-21
  • 打赏
  • 举报
回复
代码贴下?

110,532

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

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