简体   繁体   中英

Windows Forms UserControl + Panel: WPF Equivalent

In Windows Forms, I have created a Twitter application that gets the latest tweets from the Timeline using TweetSharp. I have used a UserControl and a Panel to display these. The code I've used to do this looks like this:

IEnumerable<TwitterStatus> tweets = service.ListTweetsOnHomeTimeline();

foreach (var tweet in tweets)
{
    TweetBox t = new TweetBox();

    t.username.Text = tweet.User.ScreenName; // Label
    t.display.ImageLocation = tweet.User.ProfileImageUrl; // PictureBox
    t.tweet.Text = tweet.Text; // Label
    t.info.Text = tweet.CreatedDate.ToString();
    t.Dock = DockStyle.Top;
    HomeTimeline.Controls.Add(t); // Add to HomeTimeline Panel
}

I'm now re-making this application in WPF. The UserControl is in the same format, but I'm clueless as of how to add this to the panel and dock it to the top - or the equivalent in WPF. How do I do this?

A WinForms UserControl are not the same as a WPF UserControl.

You'll have to make the UserControl again, in WPF.

Of course, you could wrap the WinForms UserControl in a WindowsFormsHost element, but that's not good practice.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM