Force TextBlock to wrap in WPF ListBox

前端 未结 3 1862
离开以前
离开以前 2020-12-02 16:13

I have a WPF listbox which displays messages. It contains an avatar on the left side and the username and message stacked vertically to the right of the avatar. The layout i

3条回答
  •  长情又很酷
    2020-12-02 16:57

    Contents of the TextBlock can be wrapped using property TextWrapping. Instead of StackPanel, use DockPanel/Grid. One more thing - set ScrollViewer.HorizontalScrollBarVisibility property to Disabled value for the ListBox.

    Updated Hidden to Disabled based on comment from Matt. Thanks Matt.

提交回复
热议问题