名称空间“http://research.microsoft.com/DynamicDataDisplay/1.0”中不存在名称“ChartPlotter”

Posted

技术标签:

【中文标题】名称空间“http://research.microsoft.com/DynamicDataDisplay/1.0”中不存在名称“ChartPlotter”【英文标题】:The name "ChartPlotter" does not exist in the namespace "http://research.microsoft.com/DynamicDataDisplay/1.0 【发布时间】:2014-12-29 21:02:59 【问题描述】:

您好,我正在使用从 codeplex.com/dynamicdatadisplay 获得的动态数据显示库。我将副本保存在根目录中,并将对 DynamicDataDisplay.dll 文件的 DLL 的引用添加到我的项目中。但是,xaml 无法识别 ChartPlotter,并说“名称“ChartPlotter”在命名空间“http://research.microsoft.com/DynamicDataDisplay/1.0”中不存在。有谁知道问题出在哪里?

XAML:

<Window x:Class="WpfApplication3.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d3="http://research.microsoft.com/DynamicDataDisplay/1.0" 
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <d3:ChartPlotter Name="plotter" Margin="10,10,20,10">
            <d3:ChartPlotter.HorizontalAxis>
                <d3:HorizontalDateTimeAxis Name="dateAxis"/>
            </d3:ChartPlotter.HorizontalAxis>
            <d3:ChartPlotter.VerticalAxis>
                <d3:VerticalIntegerAxis Name="countAxis"/>
            </d3:ChartPlotter.VerticalAxis>

            <d3:Header FontFamily="Arial" Content="Bug Information"/>
            <d3:VerticalAxisTitle FontFamily="Arial" Content="Count"/>
            <d3:HorizontalAxisTitle FontFamily="Arial" Content="Date"/>
        </d3:ChartPlotter>
    </Grid>
</Window>

代码隐藏

using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Media; // Pen

using System.IO;
using Microsoft.Research.DynamicDataDisplay; // Core functionality
using Microsoft.Research.DynamicDataDisplay.DataSources; // EnumerableDataSource
using Microsoft.Research.DynamicDataDisplay.PointMarkers; // CirclePointMarker

namespace WpfApplication3

    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    
        public MainWindow()
        
            InitializeComponent();
            Loaded += new RoutedEventHandler(Window1_Loaded);
        

        private void Window1_Loaded(object sender, RoutedEventArgs e)
        
            List<BugInfo> bugInfoList = LoadBugInfo("..\\..\\BugInfo.txt");

            DateTime[] dates = new DateTime[bugInfoList.Count];
            int[] numberOpen = new int[bugInfoList.Count];
            int[] numberClosed = new int[bugInfoList.Count];

            for (int i = 0; i < bugInfoList.Count; ++i)
            
                dates[i] = bugInfoList[i].date;
                numberOpen[i] = bugInfoList[i].numberOpen;
                numberClosed[i] = bugInfoList[i].numberClosed;
            

            var datesDataSource = new EnumerableDataSource<DateTime>(dates);
            datesDataSource.SetXMapping(x => dateAxis.ConvertToDouble(x));

            var numberOpenDataSource = new EnumerableDataSource<int>(numberOpen);
            numberOpenDataSource.SetYMapping(y => y);

            var numberClosedDataSource = new EnumerableDataSource<int>(numberClosed);
            numberClosedDataSource.SetYMapping(y => y);

            CompositeDataSource compositeDataSource1 = new
              CompositeDataSource(datesDataSource, numberOpenDataSource);
            CompositeDataSource compositeDataSource2 = new
              CompositeDataSource(datesDataSource, numberClosedDataSource);

            plotter.AddLineGraph(compositeDataSource1,
              new Pen(Brushes.Blue, 2),
              new CirclePointMarker  Size = 10.0, Fill = Brushes.Red ,
              new PenDescription("Number bugs open"));

            plotter.AddLineGraph(compositeDataSource2,
              new Pen(Brushes.Green, 2),
              new TrianglePointMarker
              
                  Size = 10.0,
                  Pen = new Pen(Brushes.Black, 2.0),
                  Fill = Brushes.GreenYellow
              ,
              new PenDescription("Number bugs closed"));

            plotter.Viewport.FitToView();

         // Window1_Loaded()

        private static List<BugInfo> LoadBugInfo(string fileName)
        
            var result = new List<BugInfo>();
            FileStream fs = new FileStream(fileName, FileMode.Open);
            StreamReader sr = new StreamReader(fs);

            string line = "";
            while ((line = sr.ReadLine()) != null)
            
                string[] pieces = line.Split(':');
                DateTime d = DateTime.Parse(pieces[0]);
                int numopen = int.Parse(pieces[1]);
                int numclosed = int.Parse(pieces[2]);
                BugInfo bi = new BugInfo(d, numopen, numclosed);
                result.Add(bi);
            
            sr.Close();
            fs.Close();
            return result;
        

     // class Window1

    public class BugInfo
    
        public DateTime date;
        public int numberOpen;
        public int numberClosed;

        public BugInfo(DateTime date, int numberOpen, int numberClosed)
        
            this.date = date;
            this.numberOpen = numberOpen;
            this.numberClosed = numberClosed;
        

    
 // ns

【问题讨论】:

【参考方案1】:

可能是“锁定”的 dll 问题。 DynamicDataDisplay.dll 必须解锁(检查其属性)。 相关话题:WPF assembly reference missing - project still building

【讨论】:

以上是关于名称空间“http://research.microsoft.com/DynamicDataDisplay/1.0”中不存在名称“ChartPlotter”的主要内容,如果未能解决你的问题,请参考以下文章

python 14 名称空间与作用域

Python--名称空间

PHP命名空间的三种引用方式:非限定名称限定名称完全限定名称

PHP命名空间的三种引用方式:非限定名称限定名称完全限定名称

python基础之名称空间和作用域函数嵌套

名称空间与作用域