问题描述
我正在尝试遵循本教程。 https://www.youtube.com/watch?v=mBlzs5owIEY
我能够用一些数据填充列表视图,当我运行模拟器时,列表视图显示正确的数据。
能否请您解释以下错误的含义?
我想了解造成问题的原因以及如何解决该问题?
错误
Severity Code Description Project File Line Suppression State
Error 'local' is an undeclared prefix. Line 7,position 10. C:\Workspaces\HelloWorld\App1\App1\App1\XAML\ListView.xaml 7
App.xaml
using System;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace App1
{
public partial class App : Application
{
public App()
{
InitializeComponent();
MainPage = new ListView();
}
protected override void OnStart()
{
}
protected override void OnSleep()
{
}
protected override void OnResume()
{
}
}
}
Debtviewmodel.cs
using System;
using System.Collections.Generic;
using System.Text;
namespace App1
{
class Debtviewmodel
{
public string[] Debt { get; set; }
public Debtviewmodel()
{
string[] debt = new string[] { "1","2","3" };
Debt = debt;
}
}
}
ListView.xaml
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:App1"
mc:Ignorable="d"
x:Class="App1.ListView">
<!-- required to map viewmodel -->
<ContentPage.BindingContext>
<local:Debtviewmodel />
</ContentPage.BindingContext>
<!-- Bind variable in view model to listview itemsource -->
<ContentPage.Content>
<StackLayout>
<ListView x:Name="lvDebt" ItemsSource="{Binding Debt}">
</ListView>
</StackLayout>
</ContentPage.Content>
</ContentPage>
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)