2012-08-10 106 views
6

我们有一个带有用户控件的WPF页面,我们使用BitmapCache - 当我们试图通过用空路径(New Path())更新属性(数据绑定)来清除此元素时,它没有完全刷新/清除。如果我稍微改变窗口大小,BitmapCache激活的区域将被完全清除。WPF的BitmapCache没有完全清除

清除/刷新使用BitmapCache的元素有什么特别的做法吗?

这是我们的代码:

<me:ScrollViewer 
    RenderedWaves="{Binding RenderedWaves}" 
    ItemTemplate="{DynamicResource DataTemplateForWaveItem}" 
    ItemsPanel="{DynamicResource ItemsPanelTemplateForWaveItems}" 
    CacheMode="BitmapCache" /> 

我想我固定的,但它并不是屡试不爽......

此代码设置路径没有按” t立即更新BitmapCache:

Protected WriteOnly Property SetGraph As Path 
Set(value As Path) 
    If value Is Nothing Then value = GetEmptyPath() 
    _graph = value 
    OnPropertyChanged(New PropertyChangedEventArgs(PropertyNameGraph)) 
End Set 
End Property 

而这种代码更新有时:

Protected WriteOnly Property SetGraph As Path 
Set(value As Path) 
    UIDispatcherLocator.UIDispatcher.Invoke(Sub() 
               If value Is Nothing Then value = GetEmptyPath() 
               _graph = value 
              End Sub, Threading.DispatcherPriority.Background) 
    OnPropertyChanged(New PropertyChangedEventArgs(PropertyNameGraph)) 
End Set 
End Property 
+0

您可能会告诉我们更多一点?为什么这么复杂? – 2012-08-10 13:25:04

+0

如果我是一个博彩人,我会说你有vidya卡问题。你能提供一个最小的例子来表明repros? – Will 2012-08-10 13:26:47

+0

您可以从代码隐藏中调用InvalidateVisual(),以查看是否有帮助 – ekholm 2012-08-10 13:30:30

回答

0

可能你刚刚作出了一个新的事件的对象必要时开火,并呼吁将设置对象时=到由一个使用声明,如果创建的临时新对象你可以使它从system.idisposable继承,或者如果你完成后将它设置为null?我不知道它的代码关闭我的头顶,但类似:

MyEvent += new event(object b); 

event(object b) 
{ 
    using (custom_ScrollViewer = new custom_ScrollViewer) 
{ 
OnScreen_ScrollViewer = Custom_ScrollViewer; 

}; 
// or 
custom_ScrollViewer = new custom_ScrollViewer; 
OnScreen_ScrollViewer = Custom_ScrollViewer; 
custom_ScrollViewer = null; 

}