<Button> > <Button.Resources> > <res:NewPaperMultiConverter x:Key="NPMC"/> > </Button.Resources> > <Button.CommandParameter> > <MultiBinding Converter="{StaticResource NPMC}"> > <MultiBinding.Bindings> > <Binding ElementName="txtWidth" Path="Text" /> > <Binding ElementName="txtHeight" Path="Text" /> > <Binding ElementName="txtName" Path="Text" /> > </MultiBinding.Bindings> > </MultiBinding> > </Button.CommandParameter> >OK</Button>And, of course, the order of the bindings is critical. I'm normally using a standard MVVM design but in this case the three parameters don't have a natural mapping to the VM - they are just used to create an object (which is in the VM). I think I'm just going to stick with the pattern and extend the VM to enable the designers to bind the textboxes directly to it - at least they are familiar with that.
<Window x:Class="WpfApplication1.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:WpfApplication1" Title="Window1" SizeToContent="WidthAndHeight"> <Window.Resources> <local:PaperInfo Name="New Paper" Height="11" Width="8.5" x:Key="PaperData"/> </Window.Resources> <Grid> <StackPanel> <TextBox Text="{Binding Source={StaticResource PaperData}, Path=Name}"/> <TextBox Text="{Binding Source={StaticResource PaperData}, Path=Height}"/> <TextBox Text="{Binding Source={StaticResource PaperData}, Path=Width}"/> <Button Command="{x:Static local:Window1.DoIt}" CommandParameter="{Binding Source={StaticResource PaperData}, Path=.}">Test</Button> </StackPanel> </Grid> </Window>C#:
using System.Windows; using System.Windows.Input; namespace WpfApplication1 { /// <summary> /// Interaction logic for Window1.xaml /// </summary> public partial class Window1 : Window { public static RoutedCommand DoIt = new RoutedCommand(); public Window1() { this.CommandBindings.Add(new CommandBinding(DoIt, DoItExecuted, DoItCanExecute)); InitializeComponent(); } public void DoItExecuted(object target, ExecutedRoutedEventArgs e) { if (e.Parameter is PaperInfo) { MessageBox.Show(((PaperInfo)e.Parameter).Name); } } public void DoItCanExecute(object sender, CanExecuteRoutedEventArgs e) { e.CanExecute = true; } } public class PaperInfo { public string Name { get; set; } public double Width { get; set; } public double Height { get; set; } } }Simplest idea I can come up with.