bool isSnapped;
async void EnsureUnsnapped()
{
// FilePicker APIs will not work if the application is in
//a snapped state
// If an app wants to show a FilePicker while snapped, it
//must attempt to unsnap first
bool unsnapped = ((Windows.UI.ViewManagement.ApplicationView.Value != Windows.UI.ViewManagement.ApplicationViewState.Snapped) || Windows.UI.ViewManagement.ApplicationView.TryUnsnap());
if (!unsnapped)
{
MessageDialog msg = new MessageDialog("Cannot open file picker in snapped view. ");
await msg.ShowAsync();
isSnapped = true;
}
else
{
isSnapped = false;
}
}
string GetNotes()
{
string response = "";
foreach (var note in NotesCollection.Notes)
{
response += "Title -> " + note.Title + Environment.NewLine + "Content -> " + note.Content + Environment.NewLine + "*****************************" + Environment.NewLine;
}
return response;
}
private async void bttnSave_Click(object sender, RoutedEventArgs e)
{
EnsureUnsnapped();
if (!isSnapped)
{
if (NotesCollection.Notes.Count > 0)
{
try
{
Windows.Storage.StorageFolder documentFolder = Windows.Storage.KnownFolders.DocumentsLibrary;
var file = await documentFolder.CreateFileAsync("Notes.txt", Windows.Storage.CreationCollisionOption.ReplaceExisting);
if (file != null)
{
await Windows.Storage.FileIO.WriteTextAsync(file, GetNotes());
MessageDialog msg = new MessageDialog("Notes are saved in the Documents Library in a file named Notes.txt");
await msg.ShowAsync();
}
}
catch
{
}
}
else
{
MessageDialog msg = new MessageDialog("No notes exists to save.");
await msg.ShowAsync();
}
}
}
的代碼已被從Windows 8在執行Windows應用商店的應用程序我得到這些警告重新定向到Windows 8.1:Windows.UI.ViewManagement.ApplicationView.TryUnsnap()是過時
'Windows.UI.ViewManagement.ApplicationView.TryUnsnap()'已過時:'Windows 8.1之後的版本可能會更改或不可用TryUnsnap。應用程序可以不斷調整大小,但不能從Windows 8.1開始捕捉。「
'Windows.UI.ViewManagement.ApplicationView.Value'已過時:'Windows 8.1之後的版本可能會更改或不可用。而是直接查詢窗口布局的大小。'
'Windows.UI.ViewManagement.ApplicationViewState'已過時:'ApplicationViewState可能會在Windows 8.1之後被更改或不可用。而是直接查詢窗口布局的大小。'
如何解決此警告信息?由於bttnSave_Click()方法也不起作用。
從錯誤本身和http://msdn.microsoft.com/en-us/library/windows/apps/dn263110.aspx 檢查部分**窗口大小模型**下的**更改說明**那裏在windows8.1中沒有快照視圖 –