For example like Visual Studio's "Output" window does.
Is there a way to do it in XAML?
// Creating textbox TextBox Mytextbox = new TextBox(); Step 2 : After creating TextBox, set the ScrollBars property of the TextBox provided by the TextBox class. // Set ScrollBars property Mytextbox. ScrollBars = ScrollBars.
Text inside a TextBlock can not be made selectable by the user. TextBoxes are used for displaying text more focused for content input or when content is needed to be made selectable by the user. The TextBox can only be set to one colour, one font size, one font type etc.
There are two predefined elements that enable scrolling in WPF applications: ScrollBar and ScrollViewer. The ScrollViewer control encapsulates horizontal and vertical ScrollBar elements and a content container (such as a Panel element) in order to display other visible elements in a scrollable area.
You can whenever you add content to that TextBox or when you listen to the event TextChanged fire this method: TextBoxBase.ScrollToEnd()
.
You could write an attached property or even better a behavior that listens to the TextChanged event and scrolls to the bottom in the callback.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With