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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:29:22+00:00 2026-06-11T00:29:22+00:00

I am attempting to fetch the users profileImageURl and bind it to an image.

  • 0

I am attempting to fetch the users profileImageURl and bind it to an image. I have got the following C# code:

namespace IIVVYTwitter
{
    public sealed partial class MainPage : Page
    {
        public MainPage()
        {
            this.InitializeComponent();
            DataContext = new ViewModel(this);
        }
    }

    class ViewModel : INotifyPropertyChanged
    {

        public User AccountImageUrl { get; set; }

        readonly Page page;

        public ViewModel(Page page)
        {
            this.page = page;
            LoadAccount = new TwitterCommand<object>(LoadAccountHolder);
        }


        public TwitterCommand<object> LoadAccount { get; set; }

        void LoadAccountHolder(object obj)
        {
            PinAuthorizer auth =
            new PinAuthorizer
            {
                Credentials = new LocalDataCredentials()
            };

            if (auth == null || !auth.IsAuthorized)
            {
                page.Frame.Navigate(typeof(oAuth));
                return;
            }

            var twitterCtx = new TwitterContext(auth);

            var accounts =
                from acct in twitterCtx.Account
                where acct.Type == AccountType.VerifyCredentials
                select acct;

            Account account = accounts.SingleOrDefault();
            LinqToTwitter.User user = account.User;

            new User
                 {
                     AccountImageUrl = user.ProfileImageUrl
                 };


            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs("AccountImageUrl"));
            }
        }

    }
}

Linked with this XAML:

<Page
    x:Class="IIVVYTwitter.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:IIVVYTwitter"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

<Grid>
    <Button Command="{Binding LoadAccount}">
         <Border>
              <Image x:Name="accountPicture" Source="{Binding AccountImageUrl}" />
         </Border>
    </Button>
</Grid>
</Page>

When I run the command through a button click, the code runs but the source of the Image is not updated.

I’m pretty sure the way I have bound the source data is flawed.

Thanks in advance.

  • 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-11T00:29:24+00:00Added an answer on June 11, 2026 at 12:29 am

    I do not see you setting the DataContext for the page anywhere. Without a properly defined DataContext, the Bindings you are using cannot be resolved to any data object. A simple example would be in the OnNavigatedTo method or the page’s constructor, you need to do something like:

    this.DataContext = new ViewModel()
    

    or something similar. There are different ways to wire up the data context depending on how you want handle viewmodel creation, lifetime, etc., but hopefully this gets you on the right path. In your code, you could also call page.DataContext = this; in your constructor.

    Update: You also need to fix the code when you fire the PropertyChanged event. You have

    if (PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs("ImageUrl"));
                }
    

    should be

    if (PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs("AccountImageUrl"));
                }
    

    Notice the change to the string passed for the property name. You were firing an change event for a property that did not exist.

    Update #2: You are returning a type of User from AccountImageUrl. You should be returning the actual http url string, not a custom type. If User has a property that hanging off of it that points to the http Url, you could update the Xaml Binding to AccountImageUrl.PropertyThatContainsRealUrl

    Update #3:
    In your code, you have

    new User
                     {
                         AccountImageUrl = user.ProfileImageUrl
                     };
    

    This is setting the AccountImageUrl on the new User object. However, you are binding to the AccountImageUrl of the ViewModel. At some point, you have to set AccountImageURl to the image url string and raise PropertyChanged on AccountImageURL. So, either before or after creating a new User, you should say this.AccountImageUrl = user.ProfileImageUrl. Hopefully I am still following your code and the changes you have made in the comments correctly.

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

Sidebar

Related Questions

I'm attempting a fetch request with the following code: NSPredicate *predicate = [NSPredicate predicateWithFormat:@dateModified
I have following entity (non-relevant fields/methods are removed). public class HitsStatsTotalDO { @Id transient
I have the following Entity: @Entity @Table @NamedQuery(name = Constants.FINDALLFINDERNAME, query = Constants.FINDALLQUERY) public
I am attempting to loop through rows in MySQL with the following code. Unfortunately,
I am attempting following code to populate an UnOrdered List dynamically. The same type
Attempting to build a C# NPAPI plugin I have found a tutorial which describes
Attempting to get Spring internationalization working. I have used classpath:messages basename, created .properties files
Attempting/struggling to get registration and sign-up working within an active admin project. I have
I have two ajax functions that fetch JSON objects using .getJSON and then build
I am attempting to fetch data from a Fusion Table, using an IN operator.

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.