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 8908069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:05:11+00:00 2026-06-15T03:05:11+00:00

I would like for instead of the image source to be bound to the

  • 0

I would like for instead of the image source to be bound to the Image property of my binding source, but to point to an async method which fetches the image remotely. I need to be able to pass in the two parameters.

Image Fetch

class ConnectImage
{
    public static async Task<BitmapImage> GetImageAsync(Uri uri, String sid)
    {
        HttpClient httpClient = new HttpClient();
        httpClient.DefaultRequestHeaders.Add("Authorization", "OAuth " + sid); 

        HttpResponseMessage response = await httpClient.GetAsync(uri);

        BitmapImage bmp = new BitmapImage();
        byte[] byteArray = await response.Content.ReadAsByteArrayAsync();

        InMemoryRandomAccessStream ras = new InMemoryRandomAccessStream();
        DataWriter writer = new DataWriter(ras.GetOutputStreamAt(0));
        writer.WriteBytes(byteArray);
        BitmapImage image = new BitmapImage();
        image.SetSource(ras);
        return image;
    }
}

ListView

<ListView
        x:Name="itemListView"
        Grid.Row="1"
        ItemsSource="{Binding Source={StaticResource itemsViewSource}}"
        IsSwipeEnabled="False"
        ItemTemplate="{StaticResource FeedItemTemplate}"/>

FeedItemTemplate

<DataTemplate x:Key="FeedItemTemplate">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <Border Width="110" Height="110">
            <Image Source="{Binding Image}" Stretch="UniformToFill" />
        </Border>
    </Grid>
</DataTemplate>
  • 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-15T03:05:12+00:00Added an answer on June 15, 2026 at 3:05 am

    Properties cannot be async, so you need an async initialization that will set the property at its completion.

    In your VM:

    public BitmapImage Image { get; private set; }
    
    public async Task Load()
    {
      Image = await ConnectImage.GetImageAsync(...);
      ... // other asynchronously-loaded properties
    }
    

    And then have your page Loaded event load your VM:

    public async void MainPage_Loaded(object sender, RoutedEventArgs e)
    {
      await vm.Load();
    }
    

    Your page will initially display with Image set to null, and when the image is loaded, it will show on the page.

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

Sidebar

Related Questions

I would like to use the group_by method, but instead of using a column
I would like to assign a variable instead of the string in my following
I would like to use Google Chrome instead of the WebKit Framework in one
I would like to use a SimpleAdapter instead of customizing an ArrayAdapter. Everything is
I would like to convert this piece of logic with purely matrix operations instead
I would like to use substitution in Vim to do unindentation manually (instead of
I would like to include cron tasks in my Capistrano deployment files instead of
I would like to make a JComboBox that has check boxes for items instead
I would like the field sub_total to update as various fields are changed instead
motivation: I would like to create a utility class so that instead of having

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.