locked
Manually close settingsFlyout RRS feed

  • Question

  • I choose to use settingsFlyout from callisto, but if I use settingsFlyout from windows controls, I still have same problem.

    Everything works quite well, but what I wish to achieve is, that click on button called btnSave will save data and close settingsFlyout. But when I try to hide it, program crashed. I don't know the exact reason, that's why I'm asking you.

    Maybe the problem is, that I add content to settingsFlyout using UserControl and inside that UserControl I have declared saveBtn. On saveBtn click I set SettingsFlyouts IsOpen on false(SettingsFlyout is declared as public).

    Declaration of SettingsFlyout:

    public Callisto.Controls.SettingsFlyout settings = new Callisto.Controls.SettingsFlyout();

    generalCommand = new SettingsCommand("defaultFilterSettings", loader.GetString("defaultFilterSettings"), (handler) => { settings.Content = new SettingsFlyouts.FilterUserControl(); settings.HeaderText = loader.GetString("defaultFilterSettings"); settings.IsOpen = true; });

    Saving attempt:

    private void btnSave_click(object sender, RoutedEventArgs e) {

    //some boring code here

    ((settingsDeclarationPage)((Frame)Window.Current.Content).Content).settings.IsOpen = false; //CRASH :(

    }


    Is there any kind of workaround?


    Friday, December 13, 2013 11:05 AM

Answers

  • It seems that settings member variable is coming out to be null, can you confirm that "settings" is not NULL?

    Can you try getting parent of UserControl and then call the public member function inside settingsDeclarationPage to set the settings.IsOpen to false?


    Thanks, Sachin

    • Marked as answer by Klemzy2013 Friday, December 13, 2013 8:18 PM
    Friday, December 13, 2013 2:48 PM
  • Note that using a save button to commit changes and close a settings fly out violates the settings guidelines. See http://msdn.microsoft.com/en-us/library/windows/apps/hh770544.aspx . Instead commit the changes as they are made and let the user dismiss the fly out by tapping elsewhere.

    That said, you don't provide enough context to know why this crashes. Something in your statement there is null, but we don't know what. You can check in the debugger to find out, but my guess is that you aren't getting the pane you expect from the nested Content calls. You could try a more direct way of storing or finding the pane to close. Again though, the real recommendation is to remove the button to meet the settings guidelines.

    --Rob

    • Marked as answer by Klemzy2013 Friday, December 13, 2013 8:18 PM
    Friday, December 13, 2013 2:59 PM
    Moderator
  • Remove the "Save" button and sync when the panel closes. That will follow the standard UI design by eliminating the commit button while leaving the sync behavior the same as you currently have.

    • Marked as answer by Klemzy2013 Friday, December 13, 2013 8:19 PM
    Friday, December 13, 2013 4:30 PM
    Moderator

All replies

  • It seems that settings member variable is coming out to be null, can you confirm that "settings" is not NULL?

    Can you try getting parent of UserControl and then call the public member function inside settingsDeclarationPage to set the settings.IsOpen to false?


    Thanks, Sachin

    • Marked as answer by Klemzy2013 Friday, December 13, 2013 8:18 PM
    Friday, December 13, 2013 2:48 PM
  • Note that using a save button to commit changes and close a settings fly out violates the settings guidelines. See http://msdn.microsoft.com/en-us/library/windows/apps/hh770544.aspx . Instead commit the changes as they are made and let the user dismiss the fly out by tapping elsewhere.

    That said, you don't provide enough context to know why this crashes. Something in your statement there is null, but we don't know what. You can check in the debugger to find out, but my guess is that you aren't getting the pane you expect from the nested Content calls. You could try a more direct way of storing or finding the pane to close. Again though, the real recommendation is to remove the button to meet the settings guidelines.

    --Rob

    • Marked as answer by Klemzy2013 Friday, December 13, 2013 8:18 PM
    Friday, December 13, 2013 2:59 PM
    Moderator
  • Yea, but the problem here is, that I have to synchronize settings with server. So that means, the program will try to synchronize for each change on SettingsPanel?
    Friday, December 13, 2013 4:17 PM
  • It seems that settings member variable is coming out to be null, can you confirm that "settings" is not NULL?

    Can you try getting parent of UserControl and then call the public member function inside settingsDeclarationPage to set the settings.IsOpen to false?


    Thanks, Sachin

    Ok, but how can I get this public member function from parent?

    Something like this(but this one does not contain settings at all)?

    (((Page)this.Parent).Frame).settings

    Friday, December 13, 2013 4:25 PM
  • Remove the "Save" button and sync when the panel closes. That will follow the standard UI design by eliminating the commit button while leaving the sync behavior the same as you currently have.

    • Marked as answer by Klemzy2013 Friday, December 13, 2013 8:19 PM
    Friday, December 13, 2013 4:30 PM
    Moderator
  • It seems that settings member variable is coming out to be null, can you confirm that "settings" is not NULL?

    Can you try getting parent of UserControl and then call the public member function inside settingsDeclarationPage to set the settings.IsOpen to false?


    Thanks, Sachin

    Ok, but how can I get this public member function from parent?

    Something like this(but this one does not contain settings at all)?

    (((Page)this.Parent).Frame).settings

    Hah, let me ****...:)

    ((Callisto.Controls.SettingsFlyout)this.Parent).IsOpen = false;

    Thanks, that works now.

    Friday, December 13, 2013 4:44 PM
  • Remove the "Save" button and sync when the panel closes. That will follow the standard UI design by eliminating the commit button while leaving the sync behavior the same as you currently have.

    Ok, I will listen to your advice. Thanks
    Friday, December 13, 2013 8:26 PM