How to keep the custom Settings Charm flyout open programmatically?

喜欢而已 提交于 2019-12-22 09:19:03

问题


I have created a custom AlarmSettingsPane in the settings charm which allows the user to give the time and also choose the audio file for alarm tone. So i implemented the file picker in the settings charm.When i click the file picker button it takes me to a new full screen where i get to pick my files, but when i select a file and open it, am directed to my home screen but the settings charm flyout gets closed. How can i preserve the state of the AlarmSettingsPane flyout and prevent it from closing programmatically? Like the settings flyout should contain the same imfo about the alarm as it was before i selected the file.

SettingsPane.Show() opens the settings charm but does not go to the alarm setting i created inside the standard settings flyout.

Please let me know if you any idea at all. Thanks

here's my code for the file picker button click event

 private async void PickAFileButton_Click(object sender, RoutedEventArgs e)
    {
        FileOpenPicker openPicker = new FileOpenPicker();
        openPicker.ViewMode = PickerViewMode.List;
        openPicker.SuggestedStartLocation = PickerLocationId.MusicLibrary;
        openPicker.FileTypeFilter.Add(".mp3");
        openPicker.FileTypeFilter.Add(".wma");

        StorageFile file = await openPicker.PickSingleFileAsync();
        if (file != null)
        {
            // Application now has read/write access to the picked file
            CustomSound.Text = file.Name;                

        }
        else
        {
            CustomSound.Text = "Operation cancelled.";
        }
    }      

回答1:


What I did was grab a copy of the UserControl.Parent before the Picker is called and store it locally in the function, this prevents the UI handlers from marking it for collection, and after the picker returns, then select the parent IsOpen back to true.

for instance:

private function ()
{
    Popup popup = this.Parent as Popup;

    Picker Code

    popup.IsOpen = true;
}

It may not be the best by the book, but it does work well.




回答2:


See if setting the IsLightDismissEnabled property of the flyout / popup to false will do the trick.




回答3:


You can try to mimic PLM (Process life management) code so that whenever you your AlarmSettingsPane gets unloaded you save the content of the page and whenever it gets loaded back you reconstruct the state of the Control. you can find some sample code in layoutawarepage in VS Split or Grid template ..

regards,



来源:https://stackoverflow.com/questions/13528598/how-to-keep-the-custom-settings-charm-flyout-open-programmatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!