2016-07-14 5 views
0

で問題がありますので、Torsten Mandelkow ModernUICharts nugetパッケージを使用しようとしています。 私は彼のcodeplexのドキュメントを新しい解決策で追跡することができ、チャートは問題なく現れました。問題は私のプロジェクトの中でそれをやろうとしたときにエラーメッセージが出ます。アセンブリリファレンスはWPFメトロチャート

The type reference cannot find a public type named 'ChartBase'. Line 18 Position 75.

私は正確にmultible回二つのプロジェクト間でコードをコピーしたことを確実にしましたが、私は同じ結果を得続けます。私はスタックオーバーフローでそれを探してみました1234 成功なし。ここで

が私のコードである

App.xaml

<Application x:Class="ReqTotalWPF.App" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     xmlns:chart="clr-namespace:De.TorstenMandelkow.MetroChart;assembly=De.TorstenMandelkow.MetroChart" 
     StartupUri="MainWindow.xaml"> 
<Application.Resources> 
    <ResourceDictionary> 
    <ResourceDictionary.MergedDictionaries> 
     <!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! --> 
     <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" /> 
     <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" /> 
     <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" /> 
     <!-- Accent and AppTheme setting --> 
      <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml" /> 
     <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" /> 

    </ResourceDictionary.MergedDictionaries> 
     <Style x:Key="MinimalChartStyle" TargetType="chart:ChartBase"> 
      <Setter Property="Width" Value="500"/> 
      <Setter Property="Height" Value="500"/> 
     </Style> 
    </ResourceDictionary> 
</Application.Resources> 

ViewModel.cs

public class ReqTotalViewModel:ObservableObject 
{ 
    class TestPageViewModel 
{ 
    public ObservableCollection<TestClass> Errors { get; private set; } 

    public TestPageViewModel() 
    { 
     Errors = new ObservableCollection<TestClass>(); 
     Errors.Add(new TestClass() { Category = "Globalization", Number = 75 }); 
     Errors.Add(new TestClass() { Category = "Features", Number = 2 }); 
     Errors.Add(new TestClass() { Category = "ContentTypes", Number = 12 }); 
     Errors.Add(new TestClass() { Category = "Correctness", Number = 83 }); 
     Errors.Add(new TestClass() { Category = "Best Practices", Number = 29 }); 
    } 

    private object selectedItem = null; 
    public object SelectedItem 
    { 
     get 
     { 
      return selectedItem; 
     } 
     set 
     { 
      // selected item has changed 
      selectedItem = value; 
     } 
    } 
} 

public class TestClass 
{ 
    public string Category { get; set; } 

    public int Number { get; set; } 
} 
} 

MainWindow.xaml

<Controls:MetroWindow x:Class="ReqTotalWPF.MainWindow" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:d="clr-namespace:ReqTotalWPF" 
    Title="ReqTotals" Height="800" Width="963" 
    xmlns:xctk ="http://schemas.xceed.com/wpf/xaml/toolkit" 
    xmlns:xcdg ="http://schemas.xceed.com/wpf/xaml/datagrid" 
    xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase" 
    xmlns:chartingToolkit="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit" 
    xmlns:metroChart="clr-namespace:De.TorstenMandelkow.MetroChart;assembly=De.TorstenMandelkow.MetroChart" 
    WindowStartupLocation="CenterScreen" 
    xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"> 


<Grid Background="#2F2C38" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Row="1" > 
     <Grid.RowDefinitions> 
      <RowDefinition Height="25"/> 
      <RowDefinition Height="30*"/> 
     </Grid.RowDefinitions> 


     <StackPanel Grid.Row="1"> 

      <metroChart:PieChart 
    Style="{StaticResource MinimalChartStyle}" 
    ChartTitle="Minimal Pie Chart" 
    ChartSubTitle="Chart with fixed width and height" 
    SelectedItem="{Binding Path=SelectedItem, Mode=TwoWay}" > 
       <metroChart:PieChart.Series> 
        <metroChart:ChartSeries 
      SeriesTitle="Errors" 
      DisplayMember="Category" 
      ValueMember="Number" 
      ItemsSource="{Binding Path=Errors}" /> 
       </metroChart:PieChart.Series> 
      </metroChart:PieChart> 
     </StackPanel> 
</Grid> 
</Controls:MetroWindow>   

MainWindow.xaml.cs

namespace ReqTotalWPF 
{ 

    public partial class MainWindow : MetroWindow 
    { 
     public MainWindow() 
     { 
     InitializeComponent(); 
     this.DataContext = new ReqTotalViewModel(); 

    } 
} 

任意の助けもいただければ幸いです。ありがとうございました!

+0

わからないが、多分それはあなたのケースで動作するに

MainWindows.xaml.cs

public partial class MainWindow : MetroWindow { public MainWindow() { InitializeComponent(); this.DataContext = new ReqTotalViewModel(); } }