C# 有时自定义加载弹出窗口不会';不显示
在我的应用程序中,每次调用时都会显示加载弹出窗口。但有些时候,它只是不显示,这是相同的情况。Popup是使用WPF创建的自定义UserControl对象 弹出窗口位于主窗口中。xaml:C# 有时自定义加载弹出窗口不会';不显示,c#,.net,wpf,user-interface,loading,C#,.net,Wpf,User Interface,Loading,在我的应用程序中,每次调用时都会显示加载弹出窗口。但有些时候,它只是不显示,这是相同的情况。Popup是使用WPF创建的自定义UserControl对象 弹出窗口位于主窗口中。xaml: <Viewbox Stretch="Fill"> <Grid> <Grid x:Name="Body" Height="768" Width="1024" Background="{StaticResource SCBPassiveCol
<Viewbox Stretch="Fill">
<Grid>
<Grid x:Name="Body" Height="768" Width="1024" Background="{StaticResource SCBPassiveColor}" />
<src:InfoPane x:Name="InfoPaneMaster" Visibility="Collapsed" VerticalAlignment="Top" HorizontalAlignment="Center" />
</Grid>
</Viewbox>
public void DisplayInfoPane(string infoText, ROPInfo infoType, int? displayTime)
{
StopTimer();
SetTimer(displayTime ?? DefaultDisplayTime);
PrepareInfoPane(infoText, infoType);
colCloseIcon.Width = new GridLength(0);
this.Visibility = Visibility.Visible;
}
实施:
<Viewbox Stretch="Fill">
<Grid>
<Grid x:Name="Body" Height="768" Width="1024" Background="{StaticResource SCBPassiveColor}" />
<src:InfoPane x:Name="InfoPaneMaster" Visibility="Collapsed" VerticalAlignment="Top" HorizontalAlignment="Center" />
</Grid>
</Viewbox>
public void DisplayInfoPane(string infoText, ROPInfo infoType, int? displayTime)
{
StopTimer();
SetTimer(displayTime ?? DefaultDisplayTime);
PrepareInfoPane(infoText, infoType);
colCloseIcon.Width = new GridLength(0);
this.Visibility = Visibility.Visible;
}
默认时间过后,弹出窗口将自动关闭(将可见性设置为折叠)
为什么有时候这个弹出窗口不显示?这与渲染有关吗?胡乱猜测:如果计时器在另一个弹出窗口打开后刚好结束,那么它的可见性没有时间设置为可见。我试试你的想法。通常最简单的解决方案是正确的。