WPF equivalent to the winform textbox.Lines property

I am converting a small win forms user control to a wpf user control in C#.

In the winforms user control the text box property textbox.Lines is used through the control. wpf does not have a textbox.Lines property but I was wondering if there was an equivalent wpf property which does the same function as the win forms property.

thanks

1 answer

  • answered 2018-01-11 19:48 Mike Strobel

    There is not an equivalent property, but similar functionality is provided.

    • Use LineCount to get the number of lines.
    • Use GetLineText(int lineIndex) to get a single line of text, from 0 through LineCount - 1.

    You can also check the length of a line and perform some other operations without having to allocate an entire string[] array.