How to have a fixed line spacing in a textbox?

c#, textbox, visual-studio, wpf

Solution

Try Setting the `LineStackingStrategy` property.

p.LineStackingStrategy = LineStackingStrategy.BlockLineHeight;

If you need some spacing before the line also, like on starting of a paragraph then you can try setting the property as:

p.LineStackingStrategy = LineStackingStrategy.MaxHeight;

Check this Post: WPF- "LineSpacing" in a TextBlock

Problem

I am creating a software for note-taking. I created an image of a notebook with the lines, and etc. Now, I want to create a textbox (or rich text box, or whatever element that works) that will add the text exactly on top of each line. However, as the user types more than a few lines, the texts gets shifted a little bit on each line, ending up very weird. I looked through many forums and questions in trying to have this fixed. Nothing helped. I'm developing it in Visual Studio, WPF project, C#. I want to add this control to the C# code, no XAML.

Original source

Related problems