2017-10-09 159 views
0

我试图在UWP应用程序中使用LiveCharts库。我通过NuGet安装了LiveCharts和LiveCharts.Uwp。我跟着提供LiveCharts网站的步骤,来重新创建他们的第一个例子,但我总是得到以下错误的XAML文件:命名空间“using:LiveCharts.Uwp”中不存在名称“CartesianChart”

  • “的CartesianChart”这个名字并不在命名空间中存在“使用:LiveCharts。 Uwp“

  • 在'CartesianChart'类型中找不到属性'系列'。

(见附图)。

XAML code and Errors

C# code and Solution Explorer

下面是我的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; } 
    } 
} 

回答

1

我无法重现此问题。我使用Visual Studio 2017并使用以下命令行:“PM> Install-Package LiveCharts.Uwp”。看起来您没有成功添加参考LiveCharts.UWP。尝试清除您的Nuget缓存并重新安装该软件包。 Here是有关如何清除缓存的参考。

1

您是否尝试过清洁您的项目? 右键单击Solution - > Clean Solution。

如果它不起作用,我也会尝试一次手动删除binobj文件夹。

相关问题