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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:47:23+00:00 2026-06-11T04:47:23+00:00

At the moment I have a simple Twitter client, on which there is a

  • 0

At the moment I have a simple Twitter client, on which there is a Refresh button which is linked to a command that refreshes the timeline through list binding. At the moment I am achieving this by:

XAML:

<Grid x:Name="TimelineGrid">
        <Button Content="Refresh Timeline" Name="RefreshTimeline" Command="{Binding RefreshCommand}" />
        <ListView Name="SearchListBox" ItemsSource="{Binding Tweets}" >
            <ListView.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal" Height="132">
                        <Image Source="{Binding ImageUrl}" 
                           Height="73" Width="73" 
                           VerticalAlignment="Top" Margin="5,10,8,0"/>
                        <StackPanel Width="auto">
                            <TextBlock Text="{Binding Name}" 
                                   Foreground="#222" FontSize="28" />
                            <TextBlock Text="{Binding Text}" 
                                    Foreground="#555" TextWrapping="Wrap" FontSize="24" />
                        </StackPanel>
                    </StackPanel>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
</Grid>

ViewModel.cs:

class ViewModel : INotifyPropertyChanged
{
    public List<Tweet> Tweets { get; set; }

    readonly Page page;

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

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

    void OnRefresh(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 timelineResponse =
            (from tweet in twitterCtx.Status
             where tweet.Type == StatusType.Home && tweet.Count == 200
             select tweet)
            .ToList();

        Tweets =
            (from tweet in timelineResponse
             select new Tweet
             {
                 Name = tweet.User.Name,
                 Text = tweet.Text,
                 ImageUrl = tweet.User.ProfileImageUrl
             })
            .ToList();

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

    public event PropertyChangedEventHandler PropertyChanged;

    public List<User> Users { get; set; }

}

Now I want to populate this timeline when the MainPage.xaml.cs is loaded.

At the moment I have this for MainPage.xaml.cs:

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


    protected override void OnNavigatedTo(NavigationEventArgs e)
    {
    }

    void InitializeTimeline()
    {
        // Get oAuth tokens (They already exist for this example).
        PinAuthorizer auth =
        new PinAuthorizer
        {
            Credentials = new LocalDataCredentials()
        };

        var twitterCtx = new TwitterContext(auth);

        //create list timelineResponse populated of last 200 statuses from users home timeline.

        var timelineResponse =
            (from tweet in twitterCtx.Status
             where tweet.Type == StatusType.Home && tweet.Count == 200
             select tweet)
            .ToList();

        //new list of Tweet (contains strings for Name, Text and ImageUrl)
        List<Tweet> Tweets = new List<Tweet>();

        //Populate list with the data collected from timeline response
        Tweets =
            (from tweet in timelineResponse
             select new Tweet
             {
                 Name = tweet.User.Name,
                 Text = tweet.Text,
                 ImageUrl = tweet.User.ProfileImageUrl
             })
            .ToList();
    }
}

Now I’m thinking the best way to go about this is to loop through this List and assign the values to their respective list values in MainPage.xaml but currently I’m struggling on how to go about that.

Any help much appreciated 🙂

  • 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-11T04:47:24+00:00Added an answer on June 11, 2026 at 4:47 am

    If I understand right, you just need the tweets to show up when you load the main page – and not just when the refresh button is clicked.

    To do that, just call the ViewModel RefreshCommand manually from the MainViewModel like this:

    ((ViewModel)DataContext).RefreshCommand.Execute(null);
    

    This goes in place of the InitializeTimeline call.

    The refresh command will then load the tweets and update the list – which is bound to the ListView anyway.

    You can then get rid of InitializeTimeline.

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

Sidebar

Related Questions

I have a simple macro (simplified version below). At the moment it assumes that
I have a simple architecture at the moment which looks a little something like
I have a simple piece of PHP ode at the moment: echo strtotime(2011-06-26T10:00:36+10:00); Which
At the moment, I have a simple app that Ajax's to a server, gets
So at the moment I have a simple reminder app that you enter some
I have a very simple package, which I eventually want to release through PyPI,
At the moment I have a very simple script. If I type the commands
At the moment I have a slider and an small input text box which
At the moment I have a jQuery do a POST to a Controller which
At the moment I have a DocumentViewer in a WPF window that displays an

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.