locked
[UWP]UWP Map Control Public? RRS feed

  • Question

  • I am working on an app that uses the map control. When the app exits, I would like to save the various pieces of data the describe the view (center, zoom factor, etc.).

    To do this, I am adding code to the OnSuspending event in the App.xaml.cs. However, I am unable to reference the map control from App.xaml.cs due to its protection level. I have tried using the field modifier (x:FieldModifier="public"), but this does not seem to work.

    How can I accomplish this?

    I have considered storing this data every time the map view is changed, and using those public variables for storage, but I have not found a suitable event for this. Is there one?

    Thank you for your help!


    • Edited by Barry Wang Monday, June 12, 2017 9:42 AM title tag
    Friday, June 9, 2017 5:05 PM

Answers

  • Hi Woogie,

    What about directly write it in your main page like described in the following doc:

    https://docs.microsoft.com/en-us/windows/uwp/launch-resume/suspend-an-app

      public MainPage()
            {
                this.InitializeComponent();
                Application.Current.Suspending += new SuspendingEventHandler(App_Suspending);
            }
    
    
            async void App_Suspending(
            Object sender,
            Windows.ApplicationModel.SuspendingEventArgs e)
            {
                // TODO: This is the time to save app data in case the process is terminated
            }

    I don't know what you mean by saying reference here. Maybe you just mean using it?

    Best regards,

    Barry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Woogie Wednesday, June 14, 2017 2:22 PM
    Monday, June 12, 2017 9:42 AM

All replies

  • Hi Woogie,

    What about directly write it in your main page like described in the following doc:

    https://docs.microsoft.com/en-us/windows/uwp/launch-resume/suspend-an-app

      public MainPage()
            {
                this.InitializeComponent();
                Application.Current.Suspending += new SuspendingEventHandler(App_Suspending);
            }
    
    
            async void App_Suspending(
            Object sender,
            Windows.ApplicationModel.SuspendingEventArgs e)
            {
                // TODO: This is the time to save app data in case the process is terminated
            }

    I don't know what you mean by saying reference here. Maybe you just mean using it?

    Best regards,

    Barry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Woogie Wednesday, June 14, 2017 2:22 PM
    Monday, June 12, 2017 9:42 AM
  • Ok, thanks...I will give that a try.
    Tuesday, June 13, 2017 10:19 PM
  • @Woogie,

    OK. We will wait for your updates.

    Best regards,

    Barry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, June 14, 2017 1:41 AM
  • It works! Many thanks.
    Wednesday, June 14, 2017 2:21 PM