Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7864301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:44:43+00:00 2026-06-02T23:44:43+00:00

I use two different webclients to pull down data to display in the main

  • 0

I use two different webclients to pull down data to display in the main page of my app. I’d like to move this code to the app.xaml.cs to download the data before the user get to the main page. I’m not sure how to set the itemssource for my listboxes on the main page. Here’s what i have so far.

Code within 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>

Thanks for the help.

UPDATE

See updated code above and my ViewModel below

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));
        }
    }

I’ve set the datacontext in the code behind for the main page. This is my first time using a ViewModel so i’m not exactly sure what i should be putting in here. The app runs without any issues, but no data is showing up.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T23:44:44+00:00Added an answer on June 2, 2026 at 11:44 pm

    Take a look at the default “Windows Phone Databound Application” Windows Phone project. This project has a ViewModel that it created within the App and this ViewModel is used by the MainPage. The MainPage then uses Binding to get to the data it needs. You can set the data in the ViewModel from the App by doing

    ViewModel.Genres = genresData.results;
    

    Then your xaml would look like

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

    In order for the UI to be updated when you set the genres, your property in the ViewModel must fire the PropertyChanged event

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

    Same thing for the Release part as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Edit: Okay, this code still doesn't allow me to use two different textures in
I am making a iPhone app that has two different targets. They use the
I am trying to use two different Core Data Models in a iPhone application,
I would like to use two different implementations for a DAO with Spring's testframework.
Can anybody help me with next: how can I use two different data contexts
I am building a search form that use two different javascript scripts. This is
I have two constructors for an objects, which use two different sets of data.
can someone give me the code example that shows how to use two different
I try to use two different jqgrid on the same page with the mvc
I have a page where I use two ASP DetailsView controls to render data

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.