2
votes

Procedure: When a MessageBox.Show in the screen, User Lock his phone or press start button and then come back to the app

When an above procedure is followed, you will never see a messagebox which was appeared before you start the above procedure, instead the phone will select the default value which is OK even in OK Cancel options. What would be the case and how would I solve it?

2
try this VisualTreeHelper.GetOpenPopups(); while reactivating your app. this may helps youMohamed Thaufeeq
where should i copy this? AND this is MessageBox.Show, does it work?gayan1991
@MohamedThaufeeq - if you're proposing an answer, please do so as an answer and not as a comment.David Makogon
NO it is not an answer, I'm still Looking for itgayan1991
@DavidMakogon I'm just giving him a suggestion, if he asks the code for it, I'll definitely give code as an answer. Am I right ?Mohamed Thaufeeq

2 Answers

1
votes

I think only way to avoid this issue is create your own pop up view as a message box.

1
votes

MessageBox supressess the Main App thread while opening, and when you press lock screen button the app, and every active thread goes in background. The main active app thread gets activated and the internally generated messagebox thread donot.

VisualTreeHelper.GetOpenPopups(); is the way you can check for all open popups. but the best and the most consistent solution is to use custom popups, messageboxes made in xaml. they never come up as seperate threads blocking the main UI thread.

A custom user control like this could help

 <Border Name="bdrLeave" Visibility="Collapsed">
            <Border.Background>
                <ImageBrush Stretch="Fill" ImageSource="/Images/LoderBackground.png"/>
            </Border.Background>
            <StackPanel>
                <StackPanel>
                    <StackPanel.Background>
                        <ImageBrush Stretch="Fill" ImageSource="/Images/Backgrounds/Main_BG.jpg"/>
                    </StackPanel.Background>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
                    <TextBlock Text="Heading" HorizontalAlignment="Center" Foreground="#FF001C68" FontWeight="Bold" Margin="0,20,150,0"/>
                        <Button content="Close"/>
                    </StackPanel>
                        <TextBlock Text="Message" TextWrapping="Wrap" HorizontalAlignment="Center" Foreground="#FF001C68" Margin="0,20,0,0"/>
                    <StackPanel Margin="0,20,0,20" Orientation="Horizontal" HorizontalAlignment="Center">
                        <Button  Content="Content" Width="130"/>
                        <Button Content="Content" width "130"/>

                    </StackPanel>
                </StackPanel>

            </StackPanel>
        </Border>