Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[XamlIl] Preserve whitspace #2619

Closed
Gillibald opened this issue Jun 5, 2019 · 4 comments
Closed

[XamlIl] Preserve whitspace #2619

Gillibald opened this issue Jun 5, 2019 · 4 comments
Labels

Comments

@Gillibald
Copy link
Contributor

Gillibald commented Jun 5, 2019

We need a way to preserve whitespaces if needed to be able to define inlines in XAML

If we have something like this:

<StackPanel Orientation="Vertical" Spacing="8">
    <TextBlock>A simple TextBlock with unformatted text.</TextBlock>
    <TextBlock>
        A <Run Classes="code">TextBlock</Run> with <Run FontWeight="Bold">differing</Run>
        <Run FontStyle="Italic">styles</Run> <Run FontSize="24">and fonts</Run>.
    </TextBlock>
    <TextBlock>
        A <Run Classes="code" Foreground="Gray">TextBlock</Run> with <Run Foreground="Red">differing</Run>
        <Run Foreground="Green">colors</Run>.
    </TextBlock>
    <TextBlock>
        A <Run Classes="code">TextBlock</Run> with <Run Foreground="Orange" FontStyle="Italic" Text="{Binding}"/>.
    </TextBlock>
    <TextBlock>
        A <Run Classes="code">TextBlock</Run> with a <LineBreak/> line break.
    </TextBlock>
</StackPanel>

We need to preserve whitespaces. Portable.Xaml was patched to support this by decorating the InlinesCollection with a special attribute.

This is the current result:

XamlIlPreserveWhitespace

Can be tested with: #2423

@FoggyFinder
Copy link
Contributor

any updates? workarounds?

@Kira-NT
Copy link
Contributor

Kira-NT commented Sep 4, 2020

If anyone will face this problem, here's little trick to force whitespace preserving: use \u200f\u200f\u200e\u0020\u200e instead of regular space (\u0020):

Result: ‏‏‎ ‎

@shartte
Copy link
Contributor

shartte commented Feb 11, 2021

XAML specification for white space: https://docs.microsoft.com/en-us/dotnet/desktop/xaml-services/white-space-processing

Avalonia also doesn't collapse white space in WPF like WPF does.

@shartte
Copy link
Contributor

shartte commented Feb 24, 2021

See kekekeks/XamlX#43

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants