How to display twitter statuses (pseudo html) using wpf (powerboots)
-
03-07-2019 - |
Question
I have a text like this: 'Rails on IIS7 http://is.gd/vWPn' (it's a tweet by shanselman). I'd like to display it somehow using wpf. How should I preprocess the text and what controls use then?
Current solution is that I create 2 controls: Label and Hyperlink and add them into a TextBlock. In powerboots it looks like this:
boots { border -borderthickness 10 -cornerradius 10 -borderbrush orange `
{ textblock { `
label 'Rails on IIS7' -backgr green; hyperlink 'http://is.gd/vWPn' -backg 'red' } `
} } -width 400
However it looks quite strange - the hyperlink is shifted, I have no idea why. alt text http://img12.imageshack.us/img12/1363/powerbootshl.jpg
One more question - is it ok to use Label to display the text? I'm asking because it seems that label can not wrap it's content. Should I use TextBlock or something completely else?
Solution
To be honest, I know nothing about PowerBoots. However:
I think you're on the right track as far as preprocessing the text goes. You're going to need to parse the text from the tweet and figure out what's an @
reference, what's a hyperlink
, etc.
With this knowledge, you can then begin to populate your TextBlock, as I think you've tried to do in the code you've presented. However, you're right in thinking that a Label
is not the right choice. In fact, the Element that you want is called a Run
. A Run
is little more than a run of text, hence the term. Ultimately, for your simple example, the code would look like:
boots { border -borderthickness 10 -cornerradius 10 -borderbrush orange `
{ textblock { `
run 'Rails on IIS7' -backgr green; hyperlink 'http://is.gd/vWPn' -backg 'red' } `
} } -width 400
assuming I got the syntax for PowerBoots right.