名称为;CartesianChart“;命名空间中不存在“0”;使用:LiveCharts.Uwp“;

名称为;CartesianChart“;命名空间中不存在“0”;使用:LiveCharts.Uwp“;,uwp,livecharts,Uwp,Livecharts,我正在尝试在UWP应用程序中使用LiveCharts库。我通过NuGet安装了LiveCharts和LiveCharts.Uwp。我按照LiveCharts网站上提供的步骤重新创建了他们的第一个示例,但在XAML文件中总是出现以下错误: 命名空间“using:LiveCharts.Uwp”中不存在名称“CartesianChart” 在类型“CartesianChart”中找不到属性“Series” (见附图) 以下是my MainPage.xaml和MainPage.xaml.cs的代

我正在尝试在UWP应用程序中使用LiveCharts库。我通过NuGet安装了LiveCharts和LiveCharts.Uwp。我按照LiveCharts网站上提供的步骤重新创建了他们的第一个示例,但在XAML文件中总是出现以下错误:

  • 命名空间“using:LiveCharts.Uwp”中不存在名称“CartesianChart”

  • 在类型“CartesianChart”中找不到属性“Series”

(见附图)

以下是my MainPage.xaml和MainPage.xaml.cs的代码:

MainPage.xaml:

<Page
    x:Class="LC2.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:LC2"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:lvc="using:LiveCharts.Uwp"
    mc:Ignorable="d">

    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <lvc:CartesianChart Series="{Binding SeriesCollection}" />
    </Grid>
</Page>

MainPage.xaml.cs

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using Windows.UI.Xaml.Controls;
using LiveCharts;
using LiveCharts.Uwp;

// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409

namespace LC2
{
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class MainPage : Page
    {
        public MainPage()
        {
            this.InitializeComponent();

            SeriesCollection = new SeriesCollection
            {
                new LineSeries
                {
                    Values = new ChartValues<double> { 3, 5, 7, 4 }
                },
                new BarSeries
                {
                    Values = new ChartValues<decimal> { 5, 6, 2, 7 }
                }
            };
        }
        public SeriesCollection SeriesCollection { get; set; }
    }
}
使用系统;
使用System.Collections.Generic;
使用System.IO;
使用System.Linq;
使用System.Runtime.InteropServices.WindowsRuntime;
使用Windows基金会;
使用Windows。
使用Windows.UI.Xaml;
使用Windows.UI.Xaml.Controls.Primitives;
使用Windows.UI.Xaml.Data;
使用Windows.UI.Xaml.Input;
使用Windows.UI.Xaml.Media;
使用Windows.UI.Xaml.Navigation;
使用Windows.UI.Xaml.Controls;
使用动态图表;
使用LiveCharts.Uwp;
//空白页项模板被记录在https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
名称空间LC2
{
/// 
///可以单独使用或在框架内导航到的空页。
/// 
公共密封部分类主页面:第页
{
公共主页()
{
this.InitializeComponent();
SeriesCollection=新的SeriesCollection
{
新系列
{
值=新图表值{3,5,7,4}
},
新酒吧系列
{
值=新图表值{5,6,2,7}
}
};
}
公共序列集合序列集合{get;set;}
}
}

我无法重现此问题。我使用Visual Studio 2017并使用以下命令行:“PM>安装程序包LiveCharts.Uwp”。看起来您尚未成功添加引用LiveCharts.UWP。请尝试清除Nuget缓存,然后重新安装该软件包。是关于如何清除缓存的参考。

您是否尝试过清理项目? 右键单击解决方案->清洁解决方案

如果不起作用,我还会尝试手动删除
bin
obj
文件夹