sinat_29203953
sinat_29203953
采纳率0%
2020-02-06 13:49 阅读 366

关于C#自定义WPF窗口最小化后点开界面闪烁问题?

5

我自定义了一个WPF窗口,头部代码是这样的

<Window x:Class="Aurora.RichTextWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:Aurora"
        mc:Ignorable="d"
        Title="Aurora"
        WindowStyle="None"
        MinWidth="600"
        MinHeight="500"
        Width="600"
        Height="500"
        WindowStartupLocation="CenterScreen"
        ResizeMode="CanResizeWithGrip"
        Loaded="Window_Loaded"
        SizeChanged="Window_SizeChanged">

在这个页面自定义了几个按钮,以实现,最小化、还原、最大化等功能,实现该功能通过改变窗口的windowState,比如

private void btnMinimize_Click(object sender, RoutedEventArgs e)
        {
            this.WindowState = WindowState.Minimized;
        }

        private void btnMaximize_Click(object sender, RoutedEventArgs e)
        {
            this.WindowState = WindowState.Maximized;
            btnRestore.Visibility = Visibility.Visible;
            btnMaximize.Visibility = Visibility.Collapsed;
        }

        private void btnRestore_Click(object sender, RoutedEventArgs e)
        {
            this.WindowState = WindowState.Normal;
            btnRestore.Visibility = Visibility.Collapsed;
            btnMaximize.Visibility = Visibility.Visible;
        }

问题是,当最小化后恢复时,界面出现黑白闪烁,类似这样:
图片说明

这个闪烁一闪而过,最后还是会呈现正确的界面

请问有大神知道如何避免出现这种闪烁吗?谢谢。

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

相关推荐