相关疑难解决方法(0)

如果ImageSource引用无法访问的Url,如何阻止WPF图像阻止?

我正在编写一个WPF应用程序并尝试使用以下XAML将图像绑定到我的视图模型:

<Image Source="{Binding Author.IconUrl, IsAsync=True}" />
Run Code Online (Sandbox Code Playgroud)

问题是图像URL由用户定义,并且通常可以指代Intranet Web服务器上托管的图像.当远程运行WPF应用程序时,它会在尝试解析现在无法访问的映像时锁定.

我认为"IsAsync"绑定属性会导致加载在后台发生,但看起来DNS解析可能仍然发生在主线程中?

即使图像无法访问,我还能做些什么来阻止我的应用锁定?

谢谢,科里

dns wpf image

7
推荐指数
1
解决办法
4270
查看次数

检测PropertyChangedEventHandler何时更改

当我观察变量时,我的PropertyChanged事件正确设置,但在代码的某处,它被重置为null,我不知道如何弄清楚这是怎么回事.

这是代码:

public event PropertyChangedEventHandler PropertyChanged;

  //this is in the NotifyTaskCompletion class, as used from the blog 
 // http://msdn.microsoft.com/en-us/magazine/dn605875.aspx
  private async Task WatchTaskAsync(Task task)
    {
        try
        {
            await task; //After this task, PropertyChanged gets set to a non-null method("Void OnPropertyChanged()")
        }
        catch
        {
        }
      //PropertyChanged, which was set to a value after the task was run, and still not null  during IdentifyCompleted getting set, is now null here
       var propertyChanged = PropertyChanged; 
        if (propertyChanged == null)
            return;
        //other code
} …
Run Code Online (Sandbox Code Playgroud)

c# wpf

2
推荐指数
1
解决办法
222
查看次数

标签 统计

wpf ×2

c# ×1

dns ×1

image ×1