对C#和UWP来说完全是新手,所以这是艰难的几天:(
我正在从VB.NET背景移动。
好的,首先使用粘贴在按钮上的Microsoft示例文档中相对简单的代码段开始。
var folderPicker = new Windows.Storage.Pickers.FolderPicker();
folderPicker.SuggestedStartLocation =
Windows.Storage.Pickers.PickerLocationId.Desktop;
folderPicker.FileTypeFilter.Add("*");
Windows.Storage.StorageFolder folder = await folderPicker.PickSingleFolderAsync();
if (folder != null)
{
// Application now has read/write access to all contents in the picked folder
// (including other sub-folder contents)
Windows.Storage.AccessCache.StorageApplicationPermissions.
FutureAccessList.AddOrReplace("PickedFolderToken", folder);
this.textBlock.Text = "Picked folder: " + folder.Name;
}
else
{
this.textBlock.Text = "Operation cancelled.";
}
接受对方法转换为异步的更改后,我收到消息"' BlankPage1'不包含' Button2_Click'的定义没有扩展方法' Button2_Click'接受第一个类型为' BlankPage1'可以找到"在BlankPage1.g.cs文件中。
case 2: // BlankPage1.xaml line 13
{
this.Button2 = (global::Windows.UI.Xaml.Controls.Button)(target);
((global::Windows.UI.Xaml.Controls.Button)this.Button2).Click += this.Button2_Click;
}
break;
错误突出显示在" this.Button2._Click;"文本。
我认为发生这种情况是因为方法名称发生了变化,但这并没有解决它。
我承认这将是一个noob错误,但我真的无法解决这个问题。
全心全意,
答案 0 :(得分:0)
检查this.Button2_Click
是否存在..如果存在,则签名应为private async void Button2_Click