0
我刚刚创建了一个名为Tipcalc> core的PCL,我正在构建它的教程是one。这里是我的 TipViewModel.csMVVM在构建时出现错误
using Cirrious.MvvmCross.ViewModels;
namespace TipCalc.Core
{
public class TipViewModel : MvxViewModel
{
private readonly ICalculation _calculation;
public TipViewModel(ICalculation calculation)
{
_calculation = calculation;
}
public override void Start()
{
_subTotal = 100;
_generosity = 10;
Recalcuate();
base.Start();
}
private double _subTotal;
public double SubTotal
{
get { return _subTotal; }
set { _subTotal = value; RaisePropertyChanged(() => SubTotal); Recalcuate(); }
}
private int _generosity;
public int Generosity
{
get { return _generosity; }
set { _generosity = value; RaisePropertyChanged(() => Generosity); Recalcuate(); }
}
private double _tip;
public double Tip
{
get { return _tip; }
set { _tip = value; RaisePropertyChanged(() => Tip); }
}
private void Recalcuate()
{
Tip = _calculation.TipAmount(SubTotal, Generosity);
}
}
}
的问题是,当我cuild这PCL,得到以下错误:
Error 1 The type or namespace name 'ICalculation' could not be found (are you missing a using directive or an assembly reference?)
TipCalc.Core
Error 2 The type or namespace name 'ICalculation' could not be found (are you missing a using directive or an assembly reference?)
Altough我的接口和类,是正确的,在服务文件夹,在项目中。
Calculation.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TipCalc.Core.Services
{
public class Calculation : ICalculation
{
public double TipAmount(double subTotal, int generosity)
{
return subTotal * ((double)generosity)/100.0;
}
}
}
而且ICalculation.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TipCalc.Core.Services
{
public interface ICalculation
{
double TipAmount(double subTotal, int generosity);
}
}
任何帮助吗?
并加上从不显示的同一句话,“大家好! –