首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >wpf应用程序不能在windows 10中加载图像,而在windows 7中可以正常工作

问wpf应用程序不能在windows 10中加载图像,而在windows 7中可以正常工作
EN

Stack Overflow用户
提问于 2017-08-21 13:58:15
回答 1查看 143关注 0票数 0

我们有一个wpf应用程序,可以在个人电脑和平板电脑上运行在windows7和windows10上。

我们有一个窗口,我们将其用作闪屏,当在Windows7中的应用程序中尝试打开它时,它会显示图像,而在windows中,它会显示空白窗口。

我们尝试将图像作为静态资源加载,在另一个线程中打开闪屏,使用7KB而不是1MB的图像,但仍然不起作用。

我们尝试在应用程序启动时打开启动画面,但它工作正常。

我们尝试用1MB的图片打开一个新项目,它正常工作了,所以我不知道在应用程序运行期间发生了什么,阻止它在Windows10中加载图片。

闪屏.xaml代码:

代码语言:javascript
复制
<Window .... WindowState="Maximized" Topmost="True" WindowStyle="None" Height="1080" Width="1980">
  <Window.Resources>
    <BitmapImage x:Key="LoadingDrill" UriSource="pack://application:,,,/Resources/Splash.png"/>
  </Window.Resources>
  <Grid x:Name="me">
    <Image Source="{StaticResource LoadingDrill}"/>
  </Grid>
</Window>

.cs代码:

代码语言:javascript
复制
    private static SplashViewer singleton;

    public static void CloseSplash()
    {
        if (singleton != null)
        {
            singleton.Close();
            singleton = null;
        }
    }

    public static void ShowSplash()
    {
        if (singleton == null)
        {
            singleton = new SplashViewer();
            singleton.Closed += Singleton_Closed;
            singleton.Show();
        }
    }

    private static void Singleton_Closed(object sender, EventArgs e)
    {
        singleton = null;
    }

    public SplashViewer()
    {
        InitializeComponent();
        me.DataContext = this;
    }

打开闪屏:

代码语言:javascript
复制
SplashViewer.ShowSplash();
///
///do something...
///
SplashViewer.CloseSplash();

再试一次:

代码语言:javascript
复制
System.Windows.Application.Current.Dispatcher.Invoke((Action)(() => { SplashViewer.ShowSplash(); }));

有没有人知道该怎么做?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-08-21 16:20:21

我们最终使用了DevExpress DXSplashScreen,它是有效的。

如果有人知道为什么它不能与常规窗口一起工作,我们也会很高兴知道。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45790161

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档