Automatic vertical scroll bar in WPF TextBlock?

后端 未结 10 1954
爱一瞬间的悲伤
爱一瞬间的悲伤 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:08

    Dont know if someone else has this problem but wrapping my TextBlock into a ScrollViewer somewhow messed up my UI - as a simple workaround I figured out that replacing the TextBlock by a TextBox like this one

    
    

    creates a TextBox that looks and behaves like a TextBlock with a scrollbar (and you can do it all in the designer).

提交回复
热议问题