you can use Multibinding and a Converter
<Button Content="Add" Command="{Binding AddCommand}"
<Button.CommandParameter>
<MultiBinding Converter="{StaticResource YourConverter}">
<Binding Path="Text" ElementName="txt1"/>
<Binding Path="Text" ElementName="txt2"/>
</MultiBinding>
</Button.CommandParameter>
</Button>
converter
public class YourConverter : IMultiValueConverter
{
public object Convert(object[] values, ...)
{
//.Net4.0
return new Tuple<int, int>((int)values[0], (int)values[1]);
//.Net < 4.0
//return values.ToArray();
}
...
}
command
private void CommandExecute(object parameter)
{
var o= (Tuple<int, int>)parameter;
var a= o.Item1;
var b= o.Item2;
Calculater calcu = new Calcu();
int c = calcu.sum(a, b);
}
ps: pls check my syntax - its written from my mind...
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…