English 中文(简体)
WP7 应用中的网络客户 发射
原标题:WP7 webclient in Application_Launching

我利用两个不同的网站,将数据引出,以显示我对口的主页。 我愿将这一代码移至用户进入主页之前下载数据。 我不敢确定如何在主页上为我的清单箱提供物品。 在这方面,我迄今为止已经做了些什么。

申请中的法典

     private void Application_Launching( object sender, LaunchingEventArgs e)
    {
        // WebClient jsonGenres
        WebClient jsonGenres = new WebClient();
        Uri apiGenres = new Uri( "http://api.beatport.com/catalog/3/genres" );
        jsonGenres.DownloadStringCompleted += newDownloadStringCompletedEventHandler (jsonGenres_GetDataCompleted);
        jsonGenres.DownloadStringAsync(apiGenres);

        // WebClient jsonHome
        WebClient jsonHome = new WebClient();
        Uri apiHome = new Uri ("http://api.beatport.com/catalog/3/beatport/home" );
        jsonHome.DownloadStringCompleted += newDownloadStringCompletedEventHandler (jsonHome_GetDataCompleted);
        jsonHome.DownloadStringAsync(apiHome);

    }

    // Deserialize genres data
    public void jsonGenres_GetDataCompleted(object sender, DownloadStringCompletedEventArgs e)
    {
        GenresHome genresData = JsonConvert.DeserializeObject<GenresHome>(e.Result);

        ViewModel.Genres = genresData.results;
        //this.listGenres.ItemsSource = genresData.results;
    }

    // Deserialize home page data
    public void jsonHome_GetDataCompleted(object sender, DownloadStringCompletedEventArgs e)
    {
        ReleasesHome homeData = JsonConvert.DeserializeObject<ReleasesHome>(e.Result);

        const int limit = 6;
        ViewModel.Releases = homeData.results.featuredReleases.Take(limit);
        //this.listRelease.ItemsSource = homeData.results.featuredReleases.Take(limit);
    }

and my main page xaml code.

                <ListBox x:Name="listRelease" ItemsSource="{Binding ReleasesHome}" Grid.Row="0" ScrollViewer.VerticalScrollBarVisibility="Disabled" >
                    <ListBox.ItemsPanel>
                        <ItemsPanelTemplate>
                            <toolkit:WrapPanel Orientation="Horizontal" />
                        </ItemsPanelTemplate>
                    </ListBox.ItemsPanel>
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Vertical">
                                <toolkit:HubTile Source="{Binding images.large.url}" MouseLeftButtonUp="releaseSelectedHandler" Margin="10" IsFrozen="True" />
                                <TextBlock Text="{Binding name}" Width="173" />
                                <ListBox ItemsSource="{Binding artists}" Height="28" ScrollViewer.VerticalScrollBarVisibility="Disabled" >
                                    <ListBox.ItemTemplate>
                                        <DataTemplate>
                                            <TextBlock Text="{Binding name}" Margin="10,0,0,0" Width="173" Style="{StaticResource PhoneTextSubtleStyle}" />
                                        </DataTemplate>
                                    </ListBox.ItemTemplate>
                                </ListBox>
                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </Grid>
        </controls:PanoramaItem>

    <!--Panorama item four-->          
    <controls:PanoramaItem x:Name="genres" Header="genres">
    <!--Single line list-->
            <Grid>
                <ListBox x:Name="listGenres" ItemsSource="{Binding GenresHome}">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Vertical">
                                <TextBlock x:Name="genresTxtBlock" Text="{Binding name}" MouseLeftButtonUp="genreSelectedHandler" Margin="10,5,0,0" Style="{StaticResource PhoneTextExtraLargeStyle}" />                                      
                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>       
            </Grid>        
    </controls:PanoramaItem>

得到帮助。

<>>>>>

见上文增订的法典和我的看法

public class MainViewModel : INotifyPropertyChanged
{
    public MainViewModel()
    {

    }

    private IEnumerable<ResultGenreHome> _genres; // backing field
    public IEnumerable<ResultGenreHome> GenresHome
    { 
        get { return _genres; }
        set
        {
            _genres = value;
            OnPropertyChanged("GenresHome");
        }
    }

    private IEnumerable<FeaturedReleasesHome> _releases; // backing field
    public IEnumerable<FeaturedReleasesHome> ReleasesHome
    {
        get { return _releases; }
        set
        {
            _releases = value;
            OnPropertyChanged("ReleasesHome");
        }
    }

    private void OnPropertyChanged(string p)
    {
        throw new NotImplementedException();
    }

    public bool IsDataLoaded
    {
        get;
        private set;
    }

    public void LoadData()
    {
        this.IsDataLoaded = true;
    }

    public event PropertyChangedEventHandler PropertyChanged;
    private void NotifyPropertyChanged(String propertyName)
    {
        PropertyChangedEventHandler handler = PropertyChanged;
        if (null != handler)
        {
            handler(this, new PropertyChangedEventArgs(propertyName));
        }
    }

我在主页后面的代码中打下了数据内容。 这是我第一次使用“观点”这样说,不能确切确定我应该在这里做些什么。 该数据没有任何问题,但没有数据显示。

最佳回答

查看“Windows 电话数据输入应用”Windows项目。 这个项目在申请中形成,主人使用本观点。 然后,主人使用电压来获取所需的数据。 你们可以通过这样做,将数据从申请人的角度来看待Model。

ViewModel.Genres = genresData.results;

之后,您的Xaml想看一想。

<ListBox ItemsSource="{Binding Genres}">
    ...
</ListBox>

为了在你确定先质时更新财产调查,你在《观点》中的财产必须烧毁财产委员会的活动。

private IEnumerable<Genre> _genres; // backing field
public IEnumerable<Genre> Genres
{ 
    get { return _genres; }
    set
    {
        _genres = value;
        OnPropertyChanged("Genres");
    }
}

释放部分也是如此。

问题回答

您可以向申请组增加财产,并安排其掌握下载和淡化的数据。

你们必须做的是用这一财产装上页的数据。

http://www.ohchr.org。

废除上诉程序,并从上诉程序中删除“启动”:

base.OnStartUp(e); Window1 w = new Window1(); w.DataContext = ViewModel; this.MainWindow = w; w.Show();





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签