C# Windows phone应用程序gui未更新

C# Windows phone应用程序gui未更新,c#,xaml,windows-phone-8.1,winrt-xaml,C#,Xaml,Windows Phone 8.1,Winrt Xaml,我正在使用WinRT xaml工具包在Windows Phone应用程序中制作一个饼图,但是当我运行这个应用程序时,我没有得到饼图的gui。 我还包括了WinRTXamlToolkit.dll和WinRTXamlToolkit.Controls.DataVisualization.dll作为参考 以下是xaml编码: <Page x:Class="App6.MainPage" xmlns:Charting="using:WinRTXamlToolkit.Controls.D

我正在使用WinRT xaml工具包在Windows Phone应用程序中制作一个饼图,但是当我运行这个应用程序时,我没有得到饼图的gui。 我还包括了WinRTXamlToolkit.dll和WinRTXamlToolkit.Controls.DataVisualization.dll作为参考

以下是xaml编码:

<Page
    x:Class="App6.MainPage"
    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:App6"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

    <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">

        <Button x:Name="ButtonRefresh" Content="Refresh" HorizontalAlignment="Left" Margin="100,57,0,0" VerticalAlignment="Top" Click="ButtonRefresh_Click"/>

        <Charting:Chart x:Name="PieChart" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="100,100,0,0" Width="400" Height="400">
        <Charting:PieSeries Margin="0" IndependentValuePath="Name" DependentValuePath="Amount" IsSelectionEnabled="True"/>
        </Charting:Chart>


    </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;
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 WinRTXamlToolkit.Controls.DataVisualization.Charting;

// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=391641

namespace App6
{
    /// <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 class FinancialStuff
        {
            public string Name { get; set; }
            public int Amount { get; set; }
        }

        public MainPage()
        {
            this.InitializeComponent();
            this.Loaded += MainPage_Loaded;
        }

        void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            LoadChartContents();
        }

        private void LoadChartContents()
        {
            Random rand = new Random();
            List<FinancialStuff> financialStuffList = new List<FinancialStuff>();
            financialStuffList.Add(new FinancialStuff() { Name = "MSFT", Amount = rand.Next(0, 200) });
            financialStuffList.Add(new FinancialStuff() { Name = "AAPL", Amount = rand.Next(0, 200) });
            financialStuffList.Add(new FinancialStuff() { Name = "GOOG", Amount = rand.Next(0, 200) });
            financialStuffList.Add(new FinancialStuff() { Name = "BBRY", Amount = rand.Next(0, 200) });

            (PieChart.Series[0] as PieSeries).ItemsSource = financialStuffList;

        }

        private void ButtonRefresh_Click(object sender, RoutedEventArgs e)
        {
            LoadChartContents();
        }
    }
}
使用系统;
使用System.Collections.Generic;
使用System.IO;
使用System.Linq;
使用System.Runtime.InteropServices.WindowsRuntime;
使用Windows基金会;
使用Windows。
使用Windows.UI.Xaml;
使用Windows.UI.Xaml.Controls;
使用Windows.UI.Xaml.Controls.Primitives;
使用Windows.UI.Xaml.Data;
使用Windows.UI.Xaml.Input;
使用Windows.UI.Xaml.Media;
使用Windows.UI.Xaml.Navigation;
使用WinRTXamlToolkit.Controls.DataVisualization.Charting;
//空白页项模板被记录在http://go.microsoft.com/fwlink/?LinkId=391641
名称空间App6
{
/// 
///可以单独使用或在框架内导航到的空页。
/// 
公共密封部分类主页面:第页
{
公共类金融凝灰岩
{
公共字符串名称{get;set;}
公共整数金额{get;set;}
}
公共主页()
{
this.InitializeComponent();
this.Loaded+=主页面_Loaded;
}
已加载无效主页(对象发送器、路由目标)
{
LoadChartContents();
}
私有void LoadChartContents()
{
Random rand=新的Random();
List financialStuffList=新列表();
Add(new FinancialStuff(){Name=“MSFT”,Amount=rand.Next(0200)});
Add(newfinancialstuff(){Name=“AAPL”,Amount=rand.Next(0200)});
Add(newfinancialstuff(){Name=“GOOG”,Amount=rand.Next(0200)});
Add(new FinancialStuff(){Name=“BBRY”,Amount=rand.Next(0200)});
(PieChart.Series[0]作为PieSseries)。ItemsSource=FinancialTuffList;
}
私有无效按钮刷新\单击(对象发送者,路由目标)
{
LoadChartContents();
}
}
}

我认为这个错误在该框架中存在了相当长的一段时间。你能试试这个吗

<Charting:Chart x:Name="PieChart" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="100,100,0,0" Width="400" Height="400">
    <charting:Chart.Series>
        <Series:PieSeries
            IndependentValuePath="Name"
            DependentValuePath="Amount"
            IsSelectionEnabled="True" />
    </charting:Chart.Series>
</Charting:Chart>


您在哪里跑步?什么版本的VST?您在输出日志中看到任何错误吗?我正在使用Visual Studio 12.0错误:无法将类型为“PieSeries”的值添加到类型为“collection`1”的集合或字典中。c:\users\comsc\documents\visual studio 2013\Projects\App6\App6\MainPage.xamlSee