有一些问题,不明白为什么会出现。我正在使用 .net 4.5 / C# 并尝试在异步函数成功后将 Content 设置为 ContentControl。我想在程序的那一部分中做的主要重点是在自己的 WPF 加载动画(Usercontrol IsLoading)和 PDF 内容(Usercontrol PDFDokument)之间切换。PDF 是在“PDFDokument”内部加载和呈现的,并且运行良好。如果需要更多信息,欢迎提出任何问题。为了让你知道,我会说我仍处于发展的初级阶段。(三年中的第一年:))
public ucPDFDocument PDFDokument = new ucPDFDocument();
public ucLoading IsLoading = new ucLoading();
protected async void lstSuchergebnis_DoubleClickItem(object sender, MouseButtonEventArgs e)
{
var tempAkte = ((ListViewItem)sender).Content as Akten;
tbctrlResultPanel.SelectedIndex = 1;
PDFDokument.IsDataChangeAllowed(false);
contSwapControls.Content = IsLoading;
await PDF(tempAkte);
contSwapControls.Content = PDFDokument; **<-- after executing this line, the ui freezes**
}
private Task PDF(Akten paramAkte)
{
Akten _tempAkte = paramAkte;
return Task.Run(() => { PDFDokument.LoadPDFDokument(_tempAkte.akt_ID, ref _DaKsManger); });
}
我尝试了使用异步加载的不同方法,但没有解决这个问题。
希望有人知道如何解决这个问题:)
非常感谢!!!