使用VS2013并构建Windows应用商店应用程序。解析器未检测到species_to_chart_itemsource_converter函数。具体错误:VS未检测命名空间中的转换器功能
The name '...' does not exist in namespace '...'
我甚至尝试过使用clr-namespace:Sustenance_V_1._0但徒劳。我也尝试在新的.cs文件中定义新的命名空间,但似乎没有任何工作。我已经提到了这个问题:xaml parser is not detecting my converter
请帮忙。
PS:我已经在MainPage本身定义了一个类的物种,但没有在这里展示它。
这是我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;
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.Shapes;
using WinRTXamlToolkit.Controls.DataVisualization.Charting;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
namespace Sustenance_V_1._0
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainPage : Page
{
//===========Converters==========//
public class species_to_chart_itemsource_converter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
var sp = parameter as species;
List<Population> data = new List<Population>();
data.Add(new Population() { Name = "Healthy", Amount = sp.healthy });
data.Add(new Population() { Name = "Healthy", Amount = sp.sick });
return data;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return true;
}
}
public MainPage()
{
this.InitializeComponent();
add_species(all_species);
link_members(all_species);
LoadChartContents(all_species);
}
void MainPage_Loaded(object sender, RoutedEventArgs e)
{
}
}
}
这是MainPage.xaml中文件的顶部:
<Page
xmlns:Charting="using:WinRTXamlToolkit.Controls.DataVisualization.Charting"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Sustenance_V_1._0"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:DataVisualization="using:WinRTXamlToolkit.Controls.DataVisualization" xmlns:Controls="using:WinRTXamlToolkit.Controls" x:Name="page"
xmlns:l="clr-namespace:Sustenance_V_1._0"
x:Class="Sustenance_V_1._0.MainPage"
mc:Ignorable="d">
<Page.Resources>
<Style TargetType="Image">
<Setter Property="Stretch" Value="Uniform"/>
</Style>
<local:species_to_chart_itemsource_converter x:Key="chart_converter"/>
</Page.Resources>
在你的命名空间中有句点是不好的做法。可能不会帮助,但你可能应该将它重命名为'Sustenance_V_1_0'(或者完全删除版本号) – DavidG
@DavidG除非这些时期表示主要功能有所不同。 ('System.Threading' vs'System.Text') –
@DavidG,我也试过。没有帮助。 –