[英]How to keep the custom Settings Charm flyout open programmatically?
我在設置超級按鈕中創建了一個自定義AlarmSettingsPane,允許用戶給出時間並選擇音頻文件作為鬧鍾鈴聲。 所以我在設置的魅力中實現了文件選擇器。當我單擊文件選擇器按鈕時,它將帶我到一個新的全屏我可以選擇我的文件,但當我選擇一個文件並打開它時,我被定向到我的主屏幕但設置魅力flyout關閉。 如何保留AlarmSettingsPane彈出窗口的狀態並阻止它以編程方式關閉? 與設置一樣,彈出窗口應包含與我選擇文件之前相同的警報信息。
SettingsPane.Show()打開設置超級按鈕,但不會轉到我在標准設置彈出窗口內創建的鬧鍾設置。
如果您有任何想法,請告訴我。 謝謝
這是我的文件選擇器按鈕單擊事件的代碼
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.";
}
}
我所做的是在調用Picker之前獲取UserControl.Parent的副本並將其本地存儲在函數中,這可以防止UI處理程序將其標記為集合,並且在選擇器返回之后,然后選擇父IsOpen返回true 。
例如:
private function ()
{
Popup popup = this.Parent as Popup;
Picker Code
popup.IsOpen = true;
}
這書可能不是最好的,但它確實運作良好。
看看將彈出/彈出窗口的IsLightDismissEnabled屬性設置為false是否可以解決問題。
您可以嘗試模擬PLM(流程生命周期管理)代碼,這樣無論何時卸載AlarmSettingsPane,您都可以保存頁面內容,無論何時加載回來,您都會重新構建Control的狀態。 你可以在VS Split或Grid模板的layoutawarepage中找到一些示例代碼。
問候,
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.