Automatic vertical scroll bar in WPF TextBlock?

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

    Something better would be:

    
        
             
        
    
    

    This makes sure that the text in your textblock does not overflow and overlap the elements below the textblock as may be the case if you do not use the grid. That happened to me when I tried other solutions even though the textblock was already in a grid with other elements. Keep in mind that the width of the textblock should be Auto and you should specify the desired with in the Grid element. I did this in my code and it works beautifully. HTH.

提交回复
热议问题