【问题标题】:Strange behavior on ShowDialog in WPFWPF 中 ShowDialog 的奇怪行为
【发布时间】:2010-10-17 12:37:26
【问题描述】:

我创建了单独的窗口,用 XAML 设计它,当我从主窗体调用 ShowDialog 时,我的对话框(窗口)似乎闪烁一次然后显示自己。这是一种常见的行为吗?在使用 Windows 窗体时,我没有注意到这一点。我还在另一台计算机上运行了应用程序,得到了同样的结果。这让我很困扰,因为我正在开发一个简单的游戏,这不是我希望用户体验的效果。


考虑到设计,这不是一个复杂的对话。它只包含标签和按钮。这是一个示例:

<Window x:Class="A_Boggle.Info"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Info" Height="300" Width="670" AllowsTransparency="True" WindowStyle="None" Background="Transparent" BorderBrush="Transparent" Foreground="Transparent" ShowInTaskbar="False" ResizeMode="NoResize" WindowStartupLocation="CenterScreen" Closing="Window_Closing">
<Grid>
    <Border Background="Transparent" Visibility="{Binding Visibility}">
        <Border BorderBrush="#FF7C4400" BorderThickness="4"
            CornerRadius="10,0,10,0" VerticalAlignment="Center"    HorizontalAlignment="Center" Height="177.5" Width="596.25">
            <Border.Background>
                <RadialGradientBrush Center="0.5,0.5" GradientOrigin="0.5,0.5" RadiusX="0.479" RadiusY="0.524">
                    <GradientStop Color="#FFF58611" Offset="0"/>
                    <GradientStop Color="#FFF58611" Offset="0.11798000335693359"/>
                    <GradientStop Color="#FFE9B231" Offset="1"/>
                </RadialGradientBrush>
            </Border.Background>
            <Border.BitmapEffect>
                <DropShadowBitmapEffect Color="Black" Opacity="0.5" Direction="270" ShadowDepth="0.7" />
            </Border.BitmapEffect>
            <Grid>
                <Separator Height="20" Name="separator1" Margin="8.75,0,6.25,45" VerticalAlignment="Bottom" />
                <Button Style="{DynamicResource OrangeButton}" Margin="406.25,0,6.25,6" Height="37.75" VerticalAlignment="Bottom" FontSize="16" Name="dialogButton" Click="dialogButton_Click"></Button>
                <Label FontFamily="Resources/#French Grotesque" FontSize="20" Foreground="#FF7C4400" Margin="8.75,20,6.25,71.25" Name="messageLabel"></Label>
            </Grid>
        </Border>
    </Border>
</Grid>

【问题讨论】:

    标签: wpf showdialog


    【解决方案1】:

    没有。在 ShowDialog 上闪烁不是常见的行为。您可以先尝试一个空窗口吗:

    new Window().ShowDialog();
    

    为了看看问题是否仍然存在?

    除了主题之外,由于性能原因,WPF/XAML 可能不是适合复杂游戏的技术(尽管对于简单的游戏必须没问题)。

    【讨论】:

    • 不,我无法通过空窗口获得它。那么,可能是因为窗户设计?这是一个静态游戏(Boggle),我认为它可以正常工作......而且它可以工作,除了这个问题。
    • 好吧,那么我想将这些项目一个一个地添加到您的对话框中(从一个空对话框开始),以便查看它们中的哪一个会导致问题。
    猜你喜欢
    • 1970-01-01
    • 2013-05-13
    • 1970-01-01
    • 1970-01-01
    • 2011-10-25
    • 1970-01-01
    • 2016-02-01
    • 2011-08-22
    • 2020-10-06
    相关资源
    最近更新 更多