gpt4 book ai didi

c# - Xamarin。当前上下文中不存在名称“authorEntry”

转载 作者:行者123 更新时间:2023-11-30 15:16:26 24 4
gpt4 key购买 nike

我是 Xamarin 的新手。我想将信息添加到 Book 类,然后使用 displayalert() 方法显示信息及其工作。但是为什么会出错?希望你们能帮我解决这个问题。先谢谢你们了。

NewBookPage.xaml

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Form.NewBookPage">
<StackLayout Margin="10,10,10,0">

<Entry x:Name="nameEntry"
Placeholder="name of the book"/>

<Entry x:Name="authorEntry"
Placeholder="name of the author"/>

<Button Text="save"
Clicked="Button_Clicked" />

</StackLayout>
</ContentPage>

NewBookPage.xaml.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace Form
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class NewBookPage : ContentPage
{
public NewBookPage ()
{
InitializeComponent ();
}

private void Button_Clicked(object sender, EventArgs e)
{
Book book = new Book()
{
Name = nameEntry.Text,
Author = authorEntry.Text

};
DisplayAlert("Success",book.Name+"/"+book.Author, "great!");
}
}
}

错误列表 enter image description here

图片

enter image description here

最佳答案

1.清理你的项目

2.重建它,将您的 XAML 文件属性(构建操作)从嵌入式资源更改为编译,重建您的项目(会抛出错误)。

3.将您的 XAML 文件属性切换回 Embedded Resource,Rebuild。

引用这个链接: https://forums.xamarin.com/discussion/96447/the-name-initializecomponent-does-not-exist-in-the-current-context

关于c# - Xamarin。当前上下文中不存在名称“authorEntry”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49592370/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com