dotnet / dotnet/wpf

Negative TextIndent can lead to the LineVisual not being positioned correctly

Open
#5,912 4 comments 1 reaction 2 assignees Claimed by @anjaligupta-dev View on GitHub
Investigate
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

* .NET Core Version: 3.1 (likely any)
* Windows version: 21H2 (19044.1348)
* Does the bug reproduce also in WPF for .NET Framework 4.8?: Yes
* Is this bug related specifically to tooling in Visual Studio (e.g. XAML Designer, Code editing, etc...)? No

**Problem description:**
I'm using negative TextIndent to try and create a hanging indent. e.g. TextIndent="-80" Margin="400,0,0,0" If the container is not wide enough (e.g. at least 485 in this case regardless of the width of the remaining inlines in the paragraph) then the linevisual starts shifting left.

**Actual behavior:**
At width 425:
![image](https://user-images.githubusercontent.com/17983788/148294370-d5972ce3-8565-4b1f-a758-759614cc413a.png)
Notice how the paragraph below (which has the same margin but without the text indent and the inlineuicontainer that would occupy/fill that indented space) will wrap and get taller.

At width 455:
![image](https://user-images.githubusercontent.com/17983788/148294409-014c8c3f-0c1c-4ac8-ae02-60e4565ee1f7.png)

Once you make the container width enough then you start to see the content correctly placed. For example at width 485:
![image](https://user-images.githubusercontent.com/17983788/148294436-774e34b1-bd6e-4ad8-bff5-c8be8da019f1.png)

And at width 525:
![image](https://user-images.githubusercontent.com/17983788/148294488-618422fa-b576-457d-9ab7-32018b2a44a5.png)

**Expected behavior:**
The paragraph should appear like that of the 2nd paragraph. The 1st inline of the 1st paragraph takes up the entirety of the text indent and so the remaining inline(s) should be just like the one without the textindent.

**Minimal repro:**
```xaml




<Setter Property="FontSize" Value="20" />
<Setter Property="Background" Value="LightGray" />
<Setter Property="BorderBrush" Value="Green" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Padding" Value="0" />






Pre

Foo


Foo




```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.