當給用戶使用時就出現了問題,選中選項後有殘影,影響了界面顯示。
解決問題時,一直認為是界面重繪,刷新的問題。於是還在網上找了段代碼據說用於刷新的,調用DoEvents()。
[csharp]
public void DoEvents()
{
DispatcherFrame frame = new DispatcherFrame();
Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background,
new DispatcherOperationCallback(ExitFrames), frame);
Dispatcher.PushFrame(frame);
}
public object ExitFrames(object f)
{
((DispatcherFrame)f).Continue = false;
return null;
}
public void DoEvents()
{
DispatcherFrame frame = new DispatcherFrame();
Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background,
new DispatcherOperationCallback(ExitFrames), frame);
Dispatcher.PushFrame(frame);
}
public object ExitFrames(object f)
{
((DispatcherFrame)f).Continue = false;
return null;
}不過依然是不行的。
試了很多辦法,最後還是從popup的屬性中找到了一個解決辦法。設置一個屬性就可以了。如下:
<Popup AllowsTransparency="True">... ...</Popup>