I’m trying to get tweets to display in a listbox which I have created on the main window of my wpf . The programme compiles but no tweets are displayed and I’m not sure what I’m doing wrong. The code is:
namespace test
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitalizeComponent();
}
static void Program (string[] args)
{
Using (StreamReader r = new StreamReader (“@1234_AllTweets.json”))
{
string json = r.ReadToEnd();
List<Tweet> tweets = JsonConvert.DeserializeObject<List<Tweet>>(json, new IsoDateTimeConverter { DateTimeFormat =“ddd MMM dd:HH:mm:as zz00 yyyy”});
foreach (Tweet tweet in tweets)
{
((MainWindow)Application.Current.MaknWindow).twittermessage.Items.Add(tweet.text);
}
}
答案 0 :(得分:-1)
Try this:
Code for the XAML binding would be something like
<ListBox ItemsSource="{Binding Path=Tweets}" />