none
请教:关闭MessageBox后,被遮住的UI没有刷新 RRS feed

  • 问题

  • Hi 专家们,

    我这里有一个问题:
    我创建一个简单的工程(演示这个问题),放置一个Button,给这个Button设置Trigger,让其在MouseMove时改变背景色。

    窗口的XAML:
    <Window x:Class="WpfApplication4.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Window1" Height="168" Width="300">
       
        <Window.Resources>
            <Style x:Key="StandardButtonStyle" TargetType="{x:Type Button}">
                <Setter Property="Foreground" Value="Black" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type Button}">
                            <Border x:Name="bdStandardButton" CornerRadius="2" Background="Gray">
                                <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" Width="Auto" />
                            </Border>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsMouseOver" Value="True">
                                    <Setter Property="Background" TargetName="bdStandardButton" Value="Red"/>
                                    <Setter Property="Foreground" Value="White"/>
                                    <Setter Property="BorderThickness" TargetName="bdStandardButton" Value="0"/>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </Window.Resources>
       
        <Grid>
            <Button Style="{DynamicResource StandardButtonStyle}" Content="abcdefghijklmn"  Height="23" Margin="12,49,12,0" Name="button1" VerticalAlignment="Top" Click="button1_Click" />
        </Grid>
    </Window>

    程序:
    namespace WpfApplication4
    {
        /// <summary>
        /// Interaction logic for Window1.xaml
        /// </summary>
        public partial class Window1 : Window
        {
            public Window1()
            {
                InitializeComponent();
            }

            private void button1_Click(object sender, RoutedEventArgs e)
            {
                MessageBox.Show("testfjskdfjskdfjskldfjsklfjsljflksjfksfsjslfsjdfl");
            }
        }
    }

    重要:切换Vista的系统颜色主题为Windows Standard(其他主题没有问题)。

    当我点击button,弹出一个MessageBox(把程序窗口移到某个可以让MessageBox弹出时能够遮住部分Button),
    当我关闭MessageBox后,这时Button的被遮住的部分没有刷新(仍然显示MouseOver背景),而没有被遮住的部分更新了。

    请帮忙分析看看。谢谢!
    (我猜这个是否是WPF的问题,因为我们遇到WPF的问题实在是太多了)

    环境:
    Vista Enterprise
    VS 2008 SP1
    2010年3月1日 9:58

答案

全部回复