tags:

views:

31

answers:

2

I create separate Window, design it with XAML and when I invoke ShowDialog from main form it seems like my dialog (Window) blinks once and then shows itself. Is it a common behavior? I didn't notice that in while working with Windows Forms. I also ran application on another computer, and get the same thing. It bothers me, cause I was developing a simple game, and it's not the effect I would like users to experience.

+1  A: 

No. Blinking on ShowDialog is not a common behaviour. Could you first try with an empty Window:

new Window().ShowDialog();

in order to see if the problem persists?

Aside from the main topic, WPF/XAML might be not the proper technology for a complicated game due to performance reasons (although for a simple one must be OK).

Vlad
No, I don't get it with an empty Window. So, it could be because of the window design? It is a static game (Boggle), I thought it will work fine... And it works, besides this issue.
sokolovic
Well, then I would suppose adding the items to your dialog one by one (starting with an empty dialog) in order to see which of them causes the problem.
Vlad
A: 

It is not a complicated dialog, considering the design. It contains just label and button. Here is one sample:

<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>

sokolovic
Could you try to remove `Visibility="{Binding Visibility}"` for test? This seems a little bit suspicious to me. (Sorry, I don't have my compiler at home, so I cannot test it myself) If this won't help, maybe you can try to remove all the transparency-related things (and in general restore the default window style)?
Vlad
I did, and the problem remains.Could this be the reason: in the main frame, I have a Windows Forms control inside a Windows Forms Host. It has overriden OnPaint method. When I did debuging, I saw that OnPaint is invoked to often... After every dialog is display, OnPaint is invoked. Maybe that could be the reason for such behaviour?
sokolovic
Well, Windows Forms' `OnPaint` should be perhaps internal to the Windows Forms part of the UI.
Vlad
Does this code blink: <Window x:Class="A_Boggle.Info" xmlns="..."xmlns:x="..." Title="Info" Height="300" Width="670" ResizeMode="NoResize" Closing="Window_Closing"> <Grid> <Border> <Border BorderBrush="#FF7C4400" BorderThickness="4" CornerRadius="10,0,10,0" VerticalAlignment="Center" HorizontalAlignment="Center" Height="177.5" Width="596.25"> </Border> </Border> </Grid> </Window> ?
Vlad
Didn't get last two comments, sorry.
sokolovic
Oh, sorry... lack of concentration! :) No, this does not blink.
sokolovic
You said that you had a Windows Forms control with overridden OnPaint. I assumed that it couldn't be the reason for the blinking, as the blinking is in WPF part of your application.
Vlad
Okay, nice. If that does not blink, let's try to add the same transparency attributes to the Window: <Window x:Class="A_Boggle.Info" Title="Info" Height="300" Width="670" AllowsTransparency="True" WindowStyle="None" Background="Transparent" BorderBrush="Transparent" Foreground="Transparent" ShowInTaskbar="False" ResizeMode="NoResize" Closing="Window_Closing"><Grid><Border><Border BorderBrush="#FF7C4400" BorderThickness="4" CornerRadius="10,0,10,0" VerticalAlignment="Center" HorizontalAlignment="Center" Height="177.5" Width="596.25"></Border></Border></Grid></Window>. Does it blink now?
Vlad
No, it doesn't.
sokolovic
Okay. Does it blink if you add back `Border.Background` and `Border.BitmapEffect`?
Vlad
Nope. But it blinks if I add back button.
sokolovic
Strange! What in the style `OrangeButton`? Try to remove everything except the button. We are on the right way :-)
Vlad
When I remove everything, it blinks. Only button is shown, with no border around dialog or anything. But button blinks when dialog is shown.
sokolovic
Does it blink if you remove the button style, too?
Vlad
Yes, it does. I'm even more confused now... :-s
sokolovic
Okay, not so many properties left :-) Which of them causes the problem? Does it blink without _any_ properties?
Vlad
Removed all windows properties; only one button is inside dialog. And it blinks SOMETIMES (not everytime, like before). It blinks if I click button on the main form that displays dialog too quickly.
sokolovic
Can you post the reduced code? By the way, is there anything special in the `A_Boggle.Info`'s constructor? Or in the code which invokes the `ShowDialog`?
Vlad
The only "special" detail is that Info dialog is shown from another dialog (Main Menu). For example, I have a Main Menu dialog with Credits button; after user presses the button, Main Menu dialog is closed and Info dialog is shown.
sokolovic
Well, nothing special indeed :-( Did you remove the Button's properties as well?
Vlad
Yep! Removed all button and windows properties, and still get it. Hm... Anyway, thanks for help, I bothered you for couple of hours! :)
sokolovic
Well, anyway gotta go to sleep now :) Good luck in your debugging!
Vlad