积极答复者
关于InvokeOperation

问题
-
在DomainServices里自定义了:
[Invoke]//
public decimal GetCompetitorsPrice(Product product)
{
//返回对手的价格
return product.ListPrice * 0.95m;
}
MainPage.xaml.cs:
private void productsGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
Product selectedProduct = (Product)productsGrid.SelectedItem;
if (selectedProduct != null)
{
catalog.GetCompetitorsPrice(selectedProduct,
(invokeOperation) =>
{
compPrice.Text = invokeOperation.Value.ToString();
}, null);//这个使用传递回调函数的方式,compPrice.Text可以得到正确的值,就是写法太麻烦了//下面写法简单是直接绑定到InvokeOperation.Value,commPrice.Text的值却为0,请问错在哪里??????请各位大大指点,谢谢
//InvokeOperation<decimal> invokeOp = catalog.GetCompetitorsPrice(selectedProduct);
//compPrice.Text = invokeOp.Value.ToString();}
}
答案
全部回复
-
我在DomainServices里又自定义了:
public bool islogin()
{
return "chenkai".Equals("chenkaige");//设定返回结果为False
}
MainPage.xaml.cs:
public MainPage()
{
InitializeComponent();InvokeOperation<bool> getresinvoke = catalog.islogin();
compPrice.Text=getresinvoke.Value.ToString();
//这个也是直接绑定到InvokeOperation.Value,commPrice.Text得到的值为false,成功!请问这次又为什么能成功取到值呢?
}