0
我目前正在Xamarin表單中構建一個應用程序。我試圖讓一個簡單的圖表元素在加載時出現在頁面上。Xamarin Microcharts擴展命名空間不被識別
我已經安裝了AloïsDeniel的Microcharts.Forms v0.6.2
包,用於我的Xamarin表單應用程序。
當我將<forms:ChartView x:Name="Chart1"/>
行添加到我的LiteChartPage.xaml
文件中時,在編譯時出現此錯誤。
'forms' is an undeclared prefix. Line 8, position 6.
我有using Microcharts;
在我LiteChartPage.xaml.cs
文件。
這裏是我的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"
xmlns:local="clr-namespace:App1"
xmlns:chart="clr-namespace:Microcharts.Forms;assembly=Microcharts.Forms"
x:Class="App1.LiteChartPage">
<forms:ChartView x:Name="Chart1"/>
</ContentPage>
這裏是LiteChartPage.xaml.cs
代碼:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using static SkiaSharp.SKCanvas;
using Microcharts;
using Entry = Microcharts.Entry;
namespace App1
{
public partial class LiteChartPage : ContentPage
{
public LiteChartPage()
{
Microcharts.Chart c = new Microcharts.BarChart();
List<Microcharts.Entry> entries = new List<Microcharts.Entry>
{
new Microcharts.Entry(200)
{
Color = SkiaSharp.SKColor.Parse("#FF1493"),
Label = "Litecoin Price",
ValueLabel = "200"
},
new Microcharts.Entry(400)
{
Color = SkiaSharp.SKColor.Parse("#BB1493"),
Label = "Bitcoin Price",
ValueLabel = "200"
},
new Microcharts.Entry(-100)
{
Color = SkiaSharp.SKColor.Parse("#FFBBD3"),
Label = "Etherium Price",
ValueLabel = "200"
},
};
c.Entries = entries;
InitializeComponent();
}
}
}
我需要添加一些參考的形式命名空間的地方?
你缺少前綴聲明「形式」 - 嘗試使用<圖表:ChartView .. /> – Ada
誤差變化的形式與大寫F '''錯誤\t CS0234 \t類型或命名空間名稱「形式」在'Microcharts'名稱空間中不存在(您是否缺少程序集引用?'' –
如果您錯過了它,我相信您將需要安裝[Microcharts.Forms](https://www.nuget.org/包/ Microcharts.Forms /)nuget包以及在您的項目 – Ada