【发布时间】:2014-01-10 11:13:20
【问题描述】:
我正在尝试向 XamDataPresenter 中的未绑定字段添加一个按钮。
这里是按钮模板:
<Style x:Key="CancelButtonTemplate" TargetType="{x:Type igDP:CellValuePresenter}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">
<Button x:Name="CancelButton" Content="Cancel" Command="{Binding CancelButtonCommand}" Width="80" Height="20" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
这是 XamDataPresenter 中的未绑定字段:
<igDP:UnboundField Name="CancelOrder" Label="Cancel Order" Column="11">
<igDP:UnboundField.Settings>
<igDP:FieldSettings CellValuePresenterStyle="{StaticResource CancelButtonTemplate}" CellHeight="12" CellWidth="50">
</igDP:FieldSettings>
</igDP:UnboundField.Settings>
</igDP:UnboundField>
</igDP:FieldLayout.Fields>
按钮绑定到的“CancelButtonCommand”是视图模型中的公共属性,我已经验证它可以与 XamDataPresenter 外部的按钮一起使用并且没有模板。
按钮显示在网格中,但当我按下它时没有任何反应。
我做错了什么?
【问题讨论】:
-
绑定有问题吗?如何纠正?
-
您尝试过我下面的建议了吗?像我的回答一样修改你的 XAML,看看它是否有效,它应该基本上告诉命令要采取什么行动。
-
感谢您的回复,问题仅是由于绑定造成的。我更改了路径并且它起作用了:
标签: wpf binding xamdatagrid