Automatic vertical scroll bar in WPF TextBlock?

后端 未结 10 1953
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-07 07:25

I have a TextBlock in WPF. I write many lines to it, far exceeding its vertical height. I expected a vertical scroll bar to appear automatically when that happe

10条回答
  •  醉酒成梦
    2020-12-07 08:22

    I tried to to get these suggestions to work for a textblock, but couldn't get it to work. I even tried to get it to work from the designer. (Look in Layout and expand the list by clicking the down-arrow "V" at the bottom) I tried setting the scrollviewer to Visible and then Auto, but it still wouldn't work.

    I eventually gave up and changed the TextBlock to a TextBox with the Readonly attribute set, and it worked like a charm.

提交回复
热议问题