zoukankan      html  css  js  c++  java
  • ImageError error #4001 in control 'Xaml1': AG_E_NETWORK_ERROR 异常

     

    这里的绑定是没有问题的,问题在于绑定发生在你设置DataContext之前,所以Image路径还没有设置成你期望的值。

     

    一种解决方法是在xaml中去掉 Source="{Binding ProductImage}"

    然后再你通过WebService取到Product以后再把这个Binding 加上。

    Something like this:

     

     

     

    Code Snippet

    private void ResponseReady(IAsyncResult asyncResult)
            {
                WebRequest request = asyncResult.AsyncState as WebRequest;
                WebResponse response = request.EndGetResponse(asyncResult);
                using (Stream responseStream = response.GetResponseStream())
                {

                    DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof(ProductList));
                    ProductList productList = jsonSerializer.ReadObject(responseStream) as ProductList;
                    new Thread(() => {
                        mygrid.Dispatcher.BeginInvoke(
                            () =>
                            {
                                mygrid.DataContext = productList.Products[0];

                             Binding binding = new Binding("ProductImage");
                             rect.SetBinding(Image.SourceProperty, binding);

                            }

                            );
                    }).Start();
                }

     http://social.microsoft.com/Forums/zh-CN/silverlightzhchs/thread/8f1d0edc-4f5c-4ac4-8d4e-7372cef97df6

  • 相关阅读:
    std::erase总结
    C++控制台应用程序运行控制台闪退
    判断当前进程是否已经打开C++
    获取当前系统语言C++
    VS中设置Qt多语言界面
    QString的功能
    安装mysql5.6
    centos6.9 PHP的编译安装并连接nginx
    centos6删除nginx
    centos6删除mysql安装
  • 原文地址:https://www.cnblogs.com/star250/p/1438951.html
Copyright © 2011-2022 走看看