1

I'm learning how to code in C# / XAML and I would like to create a simple Twitter Timeline reader using the Tweetinvi library. I'm unable to get tweets to be showed in my GridView. I'm pretty sure that my error is after I get the home timeline.

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tweetinvi;

namespace TempaTweet_2.Models
{
public class TweetViewModel
{

    public void GetTweets()
    {
        Auth.SetUserCredentials(Secret Keys);

        var tweets = Timeline.GetHomeTimeline();

        ??????????????????


    }


    public ObservableCollection<Models.Tweet> items { get; private set; } = new ObservableCollection<Models.Tweet>();


}
}

Here is my Model

namespace TempaTweet_2.Models
{
public class Tweet
{         

    public string ScreenName { get; set; }
    public string Text { get; set; }
    public string ImageUrl { get; set; }

}
}

I'm not able to figure out what comes in that after the GetHomeTimeline() so I can bind it to my XAML code.

Thank you

Francis

F_Beland
  • 11
  • 2

1 Answers1

0

I am the main developer of Tweetinvi.

What you want to do is a proxy class that will act as your TweetViewModel.

public class TweetViewModel
{
    private readonly ITweet _tweet;

    public TweetViewModel(ITweet tweet)
    {
        _tweet = tweet;
    }

    public string Text
    {
        get { return _tweet.Text; }
    }

    public string CreatedBy
    {
        get { return _tweet.CreatedBy.Name; }
    }

    // ...
}

Let me know if you have any additional question.

Linvi
  • 2,077
  • 1
  • 14
  • 28