Two way binding to different value than
Is there any way in WPF I can getb a value from a pro开发者_如何学编程perty to display in a textbox, then when the value of the textbox is updated, update a different property on a bound object? Eg: for two fields - Quantity and NewQuantity. I was thinking something along the lines of an IMultiValueConverter but if I try to add a binding to the object with , I get a "Two way binding requires a path or XPath error".
The problem is that I'm using a web service, so the proxy classes are autogenerated.
I'm not sure I'd recommend it, because it really is a horrible bit of code, but you could do this in the viewmodel to get the behaviour you want:
private string _quantity;
private string _newQuantity;
//Bind to this
public string Quantity
{
get { return _quantity; }
set { _newQuantity = value; }
}
public string NewQuantity
{
get { return _newQuantity; }
}
I thinks the only way to do it is to create a proxy property on the viewModel you bind to which will do the 'redirecting job' for you...
精彩评论