locked
how to hide message box in snapped view RRS feed

  • Question

  • While Showing Error Message Box If User Snaps the Screen to Snapped View Error Message is Still Shown.

    Any Suggestion Would Be of Great Help.

    Thanks


    Arjun

    Tuesday, October 14, 2014 6:55 AM

Answers

  • Hi Arjun,

    Message box? I assume you are working with MessageDialog class in Windows Store App.

    Try following code:

            public MainPage()
            {
                this.InitializeComponent();
                Window.Current.SizeChanged += Current_SizeChanged;
            }
    
            MessageDialog md = new MessageDialog("asdsdsdsdada");
            IAsyncOperation<IUICommand> asyncOperation;
            void Current_SizeChanged(object sender, Windows.UI.Core.WindowSizeChangedEventArgs e)
            {
                asyncOperation.Cancel();
            }
    
            private void Button_Click(object sender, RoutedEventArgs e)
            {
                asyncOperation = md.ShowAsync();
            }
    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Tuesday, October 14, 2014 9:42 AM
    Moderator
  • Not quite understand what do you mean by "But in My App After Showing PopUp It is Navigating to Other Page."? Your initial question is on how to hide the MessageDialog while the app change its view size, I cannot see why navigating block your MessageDialog. 

    I suppose each time your screen size changed, the MessageDialog will disappear immediately.

    If you really need cancel the async operation before navigating to another page, try to re-write the OnNavigateFrom method. 

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.


    Friday, October 17, 2014 3:21 PM
    Moderator

All replies

  • Hi Arjun,

    Message box? I assume you are working with MessageDialog class in Windows Store App.

    Try following code:

            public MainPage()
            {
                this.InitializeComponent();
                Window.Current.SizeChanged += Current_SizeChanged;
            }
    
            MessageDialog md = new MessageDialog("asdsdsdsdada");
            IAsyncOperation<IUICommand> asyncOperation;
            void Current_SizeChanged(object sender, Windows.UI.Core.WindowSizeChangedEventArgs e)
            {
                asyncOperation.Cancel();
            }
    
            private void Button_Click(object sender, RoutedEventArgs e)
            {
                asyncOperation = md.ShowAsync();
            }
    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Tuesday, October 14, 2014 9:42 AM
    Moderator
  • Hi Thanks For Your Reply,

    Am Using 

    var msgdialog = new Windows.UI.Popups.MessageDialog("Sample", "Title");
                                await msgdialog.ShowAsync();

    in My View Model.

    How Do i get to access This In My View?

    void Current_SizeChanged(object sender, Windows.UI.Core.WindowSizeChangedEventArgs e) { asyncOperation.Cancel();

    //This Code Snippet is in my XAML.cs File. }

    Thanks


    Arjun

    Tuesday, October 14, 2014 11:47 AM
  • Hi Arjun,

    Make sure the asyncOperation can be accessed from your code, make it static or public.

    I don't know how you manage the code, but if you simply test the code I provided by a blank app, you should be able to find out how to use it.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Wednesday, October 15, 2014 7:25 AM
    Moderator
  • Hi Jamles,

    Thanks for your reply,

    yes like u said i made that async operation Public. 

    But in My App After Showing PopUp It is Navigating to Other Page.

    That Time It is Not Cancelling the async Operation .

    Regards


    Arjun

    Wednesday, October 15, 2014 8:48 AM
  • Not quite understand what do you mean by "But in My App After Showing PopUp It is Navigating to Other Page."? Your initial question is on how to hide the MessageDialog while the app change its view size, I cannot see why navigating block your MessageDialog. 

    I suppose each time your screen size changed, the MessageDialog will disappear immediately.

    If you really need cancel the async operation before navigating to another page, try to re-write the OnNavigateFrom method. 

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.


    Friday, October 17, 2014 3:21 PM
    Moderator