问题标签 [commandparameter]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
711 浏览

c# - 与 ElementName 绑定的条件 CommandParameter,路径是子项的子项

我有以下层次结构 -

问题

  1. 如何通过 tabControl1 的选定 TabIndex 将 WebBrowser 与 CommandParameter 绑定

我正在尝试以下代码 -

  1. 我怎样才能有条件地做到这一点。例如,如果 SelectedIndex>3 那么命令应该触发。

更新

我的目标是通过 ViewModel 命令刷新网络浏览器。.xaml 文件有不同的选项卡和自己的 WebBrowser,所以通过 SelectedIndex,我可以找出我想在 CommandParameter 中传递的 WebBrowser。

0 投票
1 回答
2018 浏览

wpf - 通过上下文菜单将参数传递给 DevExpress TreeListControl

我有一个 TreeListControl,我想将选定的行作为参数传递给我的上下文菜单。所以我的控制看起来像:

看法:

代码背后

一切正常,但 CommandParameter 除外。我试过这样的事情:

他们都返回null ...我能够传递的唯一参数是:


编辑

DevExpress 回答了这个问题: http: //www.devexpress.com/Support/Center/Question/Details/Q473660

0 投票
1 回答
2363 浏览

c# - WPF 在代码中动态设置 CommandParameter 绑定

我需要动态创建一些 TreeViewItem,它们中的每一个都需要有一个绑定到 DoubleClick 鼠标操作的命令。问题是我想向这个命令传递一个参数,但我不知道该怎么做。

当前代码:

我通常以这种方式在 XAML 中设置:

如何在代码中动态设置?

0 投票
2 回答
2710 浏览

wpf - 如何获取 WPF 数据网格中的当前元素以及如何处理它?

前段时间我开始通过这个教程学习 MVVM 模式。我使用 MicroMvvm。

我有一个带有 EntityFramework 模型的 WPF 项目。我编写了 ViewModel 和 XAML 视图。我想在 DataGrid 中显示我的数据。(2 列数据和 2 个按钮列:编辑、删除)

在我的 LibraryViewModel.cs

当我按下按钮(删除/编辑)时,我想删除/编辑当前对象。我不知道如何在 MVVM 中做到这一点。

我可以这样做Command="{Binding DeleteBook, Mode=OneWay}" CommandParameter="{Binding}"吗?

如果正确,如何从CommandParameterLibraryViewModel 中获取数据?

0 投票
1 回答
245 浏览

c# - WPF将FlowDocumentScrollViewer中的当前选择获取到CommandParameter中

尝试将流查看器中的选定文本作为参数获取到命令

在模型类中:

问题是传递给处理程序的参数始终为 null

我错过了什么吗?标准的 windows Copy 命令如何获取选定的文本?

0 投票
2 回答
2850 浏览

wpf - 带有 MVVM 灯的命令参数

我正在尝试让 RelayCommand 与使用 MVVM Light 的 CommandParameter 一起工作。该命令在我的视图模型中定义,我想将选定的 ListBox 项作为参数传递。命令已绑定,但参数未绑定。这可能吗?

0 投票
1 回答
5114 浏览

c# - 从gridview rowcommand检索单元格值

嘿,我正在使用 gridview 中的按钮,每个我想分配给特定操作的按钮都涉及从我尝试使用的 gridview 列中检索某些单元格值

但它让我无法将“System.Web.UI.WebControls.GridView”类型的对象转换为“System.Web.UI.WebControls.Button”。

我也试过

它给了我以下错误指定的参数超出了有效值的范围。参数名称:索引

请注意,当我尝试指定 ButtonField 的 commandParameters 属性时,编译器说它不是 ButtonField 的有效参数,并且我在 gridview 中有 8 列,因此它没有超出范围

或者,如果可以的话,我可以使用多个选择命令按钮如何说点击了哪个?

请帮助我,我绝望了

ASP 代码:

0 投票
1 回答
473 浏览

data-binding - Windows 应用商店应用命令参数问题;不绑定到 UIElements 或其属性?

在过去的几个小时里,我一直在尝试用各种疯狂的方式将 a 传递给 a ,从不同的绑定样式到疯狂的GridViewhacky转换器。每次执行命令时,参数都显示为空。此外,当我尝试在代码隐藏中检索按钮时,它返回为 null。SelectedItemCommandParameterCommandParameter

我不知道这是否真的如此,他们是否也从 Windows 应用商店应用程序中删除了此功能,或者这是由于我使用 Visual Studio 2012 更新 2 更新失败引起的。

如果有人知道这个问题的解决方案,请分享。如果你碰巧知道事情就是这样,我也想知道。

谢谢!

0 投票
1 回答
4467 浏览

xaml - EventTrigger 中的命令参数

我正在使用 MvmmCross v3 框架和Windows.UI.Interactivity 开发WinRT 。

我想要一个带有 EventTrigger 的 TextBox,它在启动命令的事件 TextChanged 上。而且,我希望在 CommandParameter 中包含 textBox 的文本。

所以我有这个代码

但是我的 textSearch 参数等于“{Windows.UI.Xaml.Controls.TextChangedEventArgs}”,所有这些属性都为 NULL。

我还尝试在绑定中明确声明我的 ElementName,例如

但它也失败了。

谢谢

0 投票
1 回答
5222 浏览

wpf - WPF UserControl - Binding parent window as command parameter to ContextMenu MenuItem

I have a UserControl with Button inside which opens a ContextMenu when left clicked. I'm trying to pass UserControl's parent Window as a parameter to ContextMenu item's command to close that window, but with no avail. I've tried everything with RelativeSource and PlacementTarget, but parameter is always null. I'm aware that ContextMenu is not part of parent window's VisualTree. I'm currently stuck with this approach, but it is not working.

Command is a Referenced command defined in UserControl.Resources:

and it's Execute part is triggered but parameter is always null. So, my question is, what is the right way to bind parent window as CommandParameter of MenuItem. Any help is appreciated, because this thing is bothering me for almost two days.