Bugs with TextCenterVertical() ? #96
Replies: 3 comments
-
@chandra-arifin are you able to provide more detail here. I have created the following example which works as expected: using CommunityToolkit.Maui.Markup;
namespace Markup;
public class MainPage : ContentPage
{
public MainPage()
{
Content = new StackLayout
{
Children =
{
new Label
{
Text = "Without Extension",
HeightRequest = 200,
BackgroundColor = Colors.PaleGoldenrod,
VerticalTextAlignment = TextAlignment.Center
},
new Label()
{
HeightRequest = 200,
BackgroundColor = Colors.DarkOrange,
}
.TextCenterVertical()
.Text("With")
}
};
}
} This gives the result of To give a further explanation of I suspect you are wanting the Label to be positioned centrally rather than just its text? If so then you want to take a look at the |
Beta Was this translation helpful? Give feedback.
-
I use grid. 2 column.
Column 1 is label. And column 2 is Entry.
Label is not vertically center (not center as Entry component). Entry component is just entry, without text vertically center.
Tommorow i will paste my code here.
Get Outlook for Android<https://aka.ms/ghei36>
…________________________________
From: Shaun Lawrence ***@***.***>
Sent: Monday, August 1, 2022 8:10:07 PM
To: CommunityToolkit/Maui.Markup ***@***.***>
Cc: Chandra Arifin ***@***.***>; Mention ***@***.***>
Subject: Re: [CommunityToolkit/Maui.Markup] Bugs with TextCenterVertical() ? (Discussion #96)
@chandra-arifin<https://github.com/chandra-arifin> are you able to provide more detail here. I have created the following example which works as expected:
using CommunityToolkit.Maui.Markup;
namespace Markup;
public class MainPage : ContentPage
{
public MainPage()
{
Content = new StackLayout
{
Children =
{
new Label
{
Text = "Without Extension",
HeightRequest = 200,
BackgroundColor = Colors.PaleGoldenrod,
VerticalTextAlignment = TextAlignment.Center
},
new Label()
{
HeightRequest = 200,
BackgroundColor = Colors.DarkOrange,
}
.TextCenterVertical()
.Text("With")
}
};
}
}
This gives the result of
[Screenshot 2022-08-01 at 14 01 53]<https://user-images.githubusercontent.com/17139988/182154030-bb24e543-e42e-47d6-8e15-8a9df9692484.png>
To give a further explanation of TextCenterVertical vs TextCenterHorizontal vs TextCenter. Basically TextCenter applies both TextCenterVertical and TextCenterHorizontal.
I suspect you are wanting the Label to be positioned centrally rather than just its text? If so then you want to take a look at the CenterVertical<https://docs.microsoft.com/en-gb/dotnet/communitytoolkit/maui/markup/extensions/view-extensions#centervertical> method.
—
Reply to this email directly, view it on GitHub<#96 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AJQ75A3VGXEAKMINDACQDMLVW7EC7ANCNFSM55HAKZIA>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Closed and answered |
Beta Was this translation helpful? Give feedback.
-
Code 1:
Label lblDate = new Label() { VerticalTextAlignment = TextAlignment.Center, }.Text("Date");
and
Code 2:
Label lblDate = new Label().TextCenterVertical().Text("Date");
i have 2 code, code 1 runs correctly, but code 2 the text not vertically center. is it a bug? or i write the wrong extension?
i try TextCenter(), but nothing works.
Beta Was this translation helpful? Give feedback.
All reactions