vb.net - Programmatically position control in WPF -


i creating karaoke program in wpf. basically, have mediaelement plays vidioes , such, , stackpanel atop of use render stuff on top of mediaelement.

i trying programmatically add textblock stackpanel, going display lyrics. problem textblock ends in top left corner no matter write.

private lyriclabel new textblock   sub new(panel stackpanel)     lyriclabel         .foreground = brushes.white         .fontfamily = new fontfamily("verdana")         .fontsize = 20          .horizontalalignment = horizontalalignment.stretch         .verticalalignment = verticalalignment.bottom     end      panel.children.add(lyriclabel) end sub 

also, want ball or jump word word. there easy way width of each of words + space between them, or have calculate myself?

it better option use grid , entirely in xaml. grid has property if many elements in same cell, overlap. put mediaelement , textblock together, proper alignments , you're done:

<grid>     <mediaelement/>     <textblock text="{binding currentlyric}" fontsize="20" horizontalalignment="center" verticalalignment="bottom" margin="0 0 0 30"/> </grid> 

you have provide property dropping current text shown binding work, , adjust you.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -