C# 函数不';除了第一次(WP8),我叫它时它不工作

C# 函数不';除了第一次(WP8),我叫它时它不工作,c#,xaml,windows-phone-8,C#,Xaml,Windows Phone 8,我的应用程序需要解析一个JSON文件才能从网上获取信息。 当我加载应用程序时,它可以正常工作,但当我单击“刷新”按钮时,它不能正常工作。 有人能看一下代码(C#)看看我做错了什么吗 ==MainPage.xaml== <phone:PhoneApplicationPage x:Class="BitValue.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmln

我的应用程序需要解析一个JSON文件才能从网上获取信息。 当我加载应用程序时,它可以正常工作,但当我单击“刷新”按钮时,它不能正常工作。 有人能看一下代码(C#)看看我做错了什么吗

==MainPage.xaml==

<phone:PhoneApplicationPage
    x:Class="BitValue.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    shell:SystemTray.IsVisible="True">

    <!--LayoutRoot è la griglia radice in cui viene inserito tutto il contenuto della pagina-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!-- NOTA SULLA LOCALIZZAZIONE:
            Per localizzare le stringhe visualizzate copiarne i valori in chiavi denominate in modo appropriato
            nel file di risorse della lingua neutra dell'applicazione (AppResources.resx) quindi
            sostituire il valore del testo hard-coded tra le virgolette degli attributi
            con la clausola di binding il cui percorso punta a quel nome di stringa.

            Ad esempio:

                Text="{Binding Path=LocalizedResources.ApplicationTitle, Source={StaticResource LocalizedStrings}}"

            Questa associazione punta alla risorsa della stringa del modello denominata "ApplicationTitle".

            L'aggiunta delle lingue supportate nella scheda Proprietà progetto crea un
            nuovo file RESX per lingua che può trasportare i valori tradotti delle
            stringhe IU. L'associazione in questi esempi farà in modo che il valore degli
            attributi venga disegnato dal file RESX che corrisponde a
            CurrentUICulture dell'applicazione al momento del runtime.
         -->

        <!--TitlePanel contiene il nome dell'applicazione e il titolo della pagina-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <TextBlock Text="BitValue" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>

        <!--ContentPanel - inserire ulteriore contenuto qui-->
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <StackPanel>
                <TextBlock HorizontalAlignment="Center">values provided by bitstamp</TextBlock>
                <Grid Grid.Column="4" Grid.Row="4" Margin="12,0,12,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="1*" ></ColumnDefinition>
                        <ColumnDefinition  Width="1*" ></ColumnDefinition>
                        <ColumnDefinition Width="1*" ></ColumnDefinition>
                        <ColumnDefinition  Width="1*" ></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="1*"></RowDefinition>
                        <RowDefinition Height="1*"></RowDefinition>
                        <RowDefinition Height="1*"></RowDefinition>
                        <RowDefinition Height="1*"></RowDefinition>
                    </Grid.RowDefinitions>
                    <TextBlock Grid.Row="0" Text="LAST" Margin="5,10" Style="{StaticResource PhoneTextExtraLargeStyle}" Foreground="#FFEAB33C"/>
                    <TextBlock x:Name="valueLast"  Grid.Row="0" Margin="5,10" Grid.ColumnSpan="3" Grid.Column="1" Style="{StaticResource PhoneTextExtraLargeStyle}"/>

                    <TextBlock Grid.Column="0" Grid.Row="1" Text="BID" Margin="5,10" Foreground="#FF2AB437">
                    </TextBlock>

                    <TextBlock Grid.Column="2"  Grid.Row="1" Text="ASK" Margin="5,10" Foreground="#FFE83131">

                    </TextBlock>
                    <TextBlock Grid.Column="0" Grid.Row="2" Text="24H LOW" Foreground="#FFEAB33C" Margin="5,10"></TextBlock>

                    <TextBlock Grid.Column="2" Grid.Row="2" Text="24H HIGH" Foreground="#FFEAB33C" Margin="5,10"></TextBlock>

                    <TextBlock x:Name="ValueBid" Grid.Column="1" Grid.Row="1" Margin="5,10"></TextBlock>

                    <TextBlock x:Name="ValueAsk" Grid.Column="3" Grid.Row="1" Margin="5,10"></TextBlock>

                    <TextBlock x:Name="ValueLow" Grid.Column="1" Grid.Row="2" Margin="5,10"></TextBlock>

                    <TextBlock x:Name="ValueHigh" Grid.Column="3" Grid.Row="2" Margin="5,10"></TextBlock>

                </Grid>


            </StackPanel>
        </Grid>

        <!--Rimuovere il commento per vedere la griglia di allineamento che consenta di verificare che i controlli siano
            allineati ai limiti comuni.  L'immagine ha un margine superiore di -32px tenendo
            conto della barra delle applicazioni. Impostarlo su 0 (o eliminare tutti i margini)
            se la barra delle applicazioni è nascosta.

            Prima della spedizioni, eliminare questo XAML e l'immagine stessa.-->
        <!--<Image Source="/Assets/AlignmentGrid.png" VerticalAlignment="Top" Height="800" Width="480" Margin="0,-32,0,0" Grid.Row="0" Grid.RowSpan="2" IsHitTestVisible="False" />-->
    </Grid>
    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton IconUri="/Assets/refresh2.png" Text="refresh" Click="refreshClick"/>
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem Text="about"/>
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>
</phone:PhoneApplicationPage>
==Result.cs==

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Serialization;

namespace BitValue
{
    [DataContract]
    public class Result
    {
        [DataMember(Name = "last")]
        public string LAST
        {
            get;
            set;
        }
        [DataMember(Name = "ask")]
        public string ASK
        {
            get;
            set;
        }
        [DataMember(Name = "bid")]
        public string BID
        {
            get;
            set;
        }
        [DataMember(Name = "low")]
        public string LOW
        {
            get;
            set;
        }
        [DataMember(Name = "high")]
        public string HIGH
        {
            get;
            set;
        }
        [DataMember(Name = "timestamp")]
        public string TIMESTAMP
        {
            get;
            set;
        }
    }
}

提前感谢。

问题是您的代码实际上看起来。好吧问题在API中,您将得到一个缓存结果(因此,第二次,缓存由webclient返回)


看看这里:

到底发生了什么?工作不是什么意思吗?这是家庭作业吗?正如标题所说,当第一次调用函数refresh()时(当加载组件时),它工作正常,但当我在refreshClick事件中调用它时(当我单击按钮刷新时),它不工作“不工作”意味着
refresh()
未被调用或
OnOpenReadCompleted()未调用
或调用了OnOpenReadCompleted(),但该方法中的结果有问题吗?这哪里不符合预期?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Serialization;

namespace BitValue
{
    [DataContract]
    public class Result
    {
        [DataMember(Name = "last")]
        public string LAST
        {
            get;
            set;
        }
        [DataMember(Name = "ask")]
        public string ASK
        {
            get;
            set;
        }
        [DataMember(Name = "bid")]
        public string BID
        {
            get;
            set;
        }
        [DataMember(Name = "low")]
        public string LOW
        {
            get;
            set;
        }
        [DataMember(Name = "high")]
        public string HIGH
        {
            get;
            set;
        }
        [DataMember(Name = "timestamp")]
        public string TIMESTAMP
        {
            get;
            set;
        }
    }
}