WPF – pass multiple parameters to a Command
public class SendCommand : ICommand
{
public void Execute(object parameter)
{
var labels = ((object[]) parameter).OfType<Label>();
} public bool CanExecute(object parameter)
{
return true;
} public event EventHandler CanExecuteChanged = delegate {};
} public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
DataContext = this;
SendCommand = new SendCommand();
} public ICommand SendCommand { get; set; }
} public class PassThroughConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
return values.ToArray();
} public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
<Window x:Class="WpfApplication5.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:wpfApplication5="clr-namespace:WpfApplication5"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<wpfApplication5:PassThroughConverter x:Key="PassthroughConverter" />
</Window.Resources>
<Grid>
<StackPanel>
<Label Name="Greeting">Hello</Label>
<Label Name="Farewell">Goodbye</Label>
<Button Command="{Binding SendCommand}">Hit me
<Button.CommandParameter>
<MultiBinding Converter="{StaticResource PassthroughConverter}">
<Binding Path="." ElementName="Greeting"></Binding>
<Binding Path="." ElementName="Farewell"></Binding>
</MultiBinding>
</Button.CommandParameter>
</Button>
</StackPanel>
</Grid>
</Window>
WPF – pass multiple parameters to a Command的更多相关文章
- How to pass multiple parameters in PowerShell invoke-restmethod
Link: http://www.tagwith.com/question_322855_how-to-pass-parameters-in-powershell-invoke-restmethod- ...
- Can't bind multiple parameters ('header' and 'parameters') to the request's content.
2019-01-23 15:46:29.012+08:00 ERROR [6]: System.InvalidOperationException: Can't bind multiple param ...
- How to Choose the Best Way to Pass Multiple Models in ASP.NET MVC
Snesh Prajapati, 8 Dec 2014 http://www.codeproject.com/Articles/717941/How-to-Choose-the-Best-Way-to ...
- WPF中ContextMenu(右键菜单)使用Command在部分控件上默认为灰色的处理方法
原文:WPF中ContextMenu(右键菜单)使用Command在部分控件上默认为灰色的处理方法 问题描述 今天发现如果我想在一个TextBlock弄一个右键菜单,并且使用Command绑定,结果发 ...
- EXEC sp_executesql with multiple parameters
传递多个参数 https://stackoverflow.com/questions/28481189/exec-sp-executesql-with-multiple-parameters http ...
- WPF: 使用CommandManager.InvalidateRequerySuggested手动更新Command状态
WPF判断命令(Command)是否能够执行是通过ICommand.CanExecute事件,在实际程序中路由命令一般是通过CommandBinding来使命令得到实际操作代码,但是这个CanExec ...
- WPF Datagrid multiple selecteditems in MVVM
I can assure you: SelectedItems is indeed bindable as a XAML CommandParameter After a lot of digging ...
- Part 89 to 91 Talking about pass the parameters in thread
Part 89 ParameterizedThreadStart delegate Use ParameterizedThreadStart delegate to pass data to th ...
- JNI: Passing multiple parameters in the function signature for GetMethodID
http://stackoverflow.com/questions/7940484/jni-passing-multiple-parameters-in-the-function-signature ...
随机推荐
- SQL Server多表多列更新
student表: lag表: 要求将student表stu_id列为1的stu_nick列和stu_phont列的数据更新为lag表的lag_nick列和lag_phone列. SQL语句: upd ...
- MVC - 18.缓存
1.使用输出缓存 (不灵活,问题比较多,不建议使用) /// <summary> /// datagrid列表 /// </summary> /// <returns&g ...
- php页面判断是 iphone还是andriod的浏览器&通过 URL types在浏览器打开app(转)
http://blog.csdn.net/totogo2010/article/details/8925483 解决一个二维码不同手机扫描下载时跳转的问题 判断后跳转对应的app下载 <?php ...
- Delphi编程建议遵守的规范2---命名规范
1.1.形参命名建议 所有形参的名称都应当表达出它的用途.如果合适的话,形参的名称最好以字母a 为前缀,例如: procedure SomeProc(aUserName:string; aUserAg ...
- SQL语法中的子查询Subqueries
记一下样子. 明白它的应用场景. SELECT account_id, product_cd, cust_id, avail_balance FROM account WHERE open_emp_i ...
- WCF 回调中操作线程
回调的类 [CallbackBehavior(ConcurrencyMode = ConcurrencyMode.Reentrant, UseSynchronizationContext = fals ...
- CI登录验证
预先加载数据库操作类和Session类 即在autoload.php中,$autoload['libraries'] = array('database', 'session'); a. 注: 使用s ...
- DNX/ASP.NET 5的xUnit入门向导
(此文章同时发表在本人微信公众号"dotNET每日精华文章",欢迎右边二维码来关注.) 题记:想必很多人已经和我一样在使用ASP.NET 5开发真实世界的应用了,那么做好单元测试和 ...
- C++Primer快速浏览笔记-复合类型
C++Primer2.3节介绍了两种复合类型:引用和指针 1.引用 引用并非对象,它只是为一个已经存在的对象所起的别名. 一旦初始化完成,引用将和它的初始值对象一直绑定在一起,不能重新绑定到另一个对象 ...
- JSHint配置详解
Also available on Github JSHint配置详解 增强参数(Enforcing Options) 本类参数设为true,JSHint会产生更多告警. bitwise 禁用位运算符 ...