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

How to make label text auto wrap? #5143

Closed
dayAndnight2018 opened this issue Dec 6, 2020 · 6 comments
Closed

How to make label text auto wrap? #5143

dayAndnight2018 opened this issue Dec 6, 2020 · 6 comments

Comments

@dayAndnight2018
Copy link

No description provided.

@Gillibald
Copy link
Contributor

Just host a TextBlock inside the Label

<Label><TextBlock/></Label>

@Gillibald
Copy link
Contributor

You can also define a ContentTemplate that is using a TextBlock with TextWrapping="Wrap"

@maxkatz6
Copy link
Member

maxkatz6 commented Dec 6, 2020

I haven't tested it, but code below also should work, and it will be more reusable.

Define style:

<Style Selector="Label.wrap > TextBlock">
   <Setter Property="TextWrapping" Value="Wrap" />
</Style>

And use it in another place:

<Label Classes="wrap" Content="Looooooooooong text" />

@dayAndnight2018
Copy link
Author

Just host a TextBlock inside the Label

<Label><TextBlock/></Label>

I find it when I use a textblock to make it word wrap, it works. But when there is a scrollviewer outside of the textblock, it not work no longer.

@dayAndnight2018
Copy link
Author

I haven't tested it, but code below also should work, and it will be more reusable.

Define style:

<Style Selector="Label.wrap > TextBlock">
   <Setter Property="TextWrapping" Value="Wrap" />
</Style>

And use it in another place:

<Label Classes="wrap" Content="Looooooooooong text" />

thanks, i will hava a try

@dayAndnight2018
Copy link
Author

Just host a TextBlock inside the Label
<Label><TextBlock/></Label>

I find it when I use a textblock to make it word wrap, it works. But when there is a scrollviewer outside of the textblock, it not work no longer.

I have found its solution in #5020 , thanks anyway

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

No branches or pull requests

3 participants