c# - 可以将整个对象绑定(bind)到 XAML 中的 CommandParameter 吗?

标签 c# silverlight xaml

我在接收对象列表的列表框中有一个链接按钮。我正在使用 ListBox.ItemTemplate 和 DataTemplate 来布置列表框项目。我可以将当​​前正在绑定(bind)的整个对象绑定(bind)到 linkbutton 的命令参数吗?我试过使用

CommandParameter={绑定(bind)数据}

CommandParameter={Binding DataItem}

但我总是在输出中收到错误消息,即“Data”或“DataItem”不是所述对象的属性。这可能吗?

最佳答案

试试这个

CommandParameter = {绑定(bind)}

它将绑定(bind)到用于生成项目的当前对象

关于c# - 可以将整个对象绑定(bind)到 XAML 中的 CommandParameter 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3857213/

相关文章:

c# - 为什么连接两个空字符串会产生一个空字符串?

c# - 如何使用路径列表创建层次结构?

c# - 通过代码隐藏将 silverlight 加载到 aspx 页面

xaml - UWP/XAML : What is the difference between theming in a page's Resources, 在单独的 ResourceDictionary 文件中,还是在 App.xaml 中?

c# - 在 C# 中挂接 KeyPress 事件

c# - 如何在不使用 C# 将其设置为默认打印机的情况下直接打印到 zebra 打印机?

c# - 为什么没有 MouseMoveEvent——或者,如何为鼠标移动事件使用 AddHandler

c# - 在 ScrollViewer SL4 的焦点更改时将控件引入 ViewPort

wpf - 如何在 WPF 或 Silverlight 应用程序中使用 EPS 文件?

c# - 放大 ListView 内容而不缩放滚动条