Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Enhancement] AutoFitLabel #1164

Closed
26 changes: 26 additions & 0 deletions samples/XCT.Sample/Pages/Views/AutoFitLabelPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8" ?>
<pages:BasePage
x:Class="Xamarin.CommunityToolkit.Sample.Pages.Views.AutoFitLabelPage"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:pages="clr-namespace:Xamarin.CommunityToolkit.Sample.Pages"
xmlns:vm="clr-namespace:Xamarin.CommunityToolkit.Sample.ViewModels"
xmlns:xct="http://xamarin.com/schemas/2020/toolkit">

<pages:BasePage.BindingContext>
<vm:WelcomeViewModel />
</pages:BasePage.BindingContext>

<pages:BasePage.Content>
<StackLayout>
<xct:AutoFitLabel
HorizontalOptions="CenterAndExpand"
Text="{Binding TextToFit}"
VerticalOptions="CenterAndExpand" />
<Entry
HorizontalOptions="CenterAndExpand"
Text="{Binding TextToFit}"
VerticalOptions="CenterAndExpand" />
</StackLayout>
</pages:BasePage.Content>
</pages:BasePage>
7 changes: 7 additions & 0 deletions samples/XCT.Sample/Pages/Views/AutoFitLabelPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Xamarin.CommunityToolkit.Sample.Pages.Views
{
public partial class AutoFitLabelPage : BasePage
{
public AutoFitLabelPage() => InitializeComponent();
}
}
13 changes: 13 additions & 0 deletions samples/XCT.Sample/ViewModels/Views/AutoFitViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace Xamarin.CommunityToolkit.Sample.ViewModels.Views
{
public class AutoFitViewModel : BaseViewModel
{
string textToFit = "Change the text to see the autofit in action!";

public string TextToFit
{
get => textToFit;
set => SetProperty(ref textToFit, value);
}
}
}
5 changes: 4 additions & 1 deletion samples/XCT.Sample/ViewModels/Views/ViewsGalleryViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ protected override IEnumerable<SectionModel> CreateItems() => new[]
"The UniformGrid is just like the Grid, with all rows and columns will have the same size."),

new SectionModel(typeof(PopupGalleryPage), "Popup",
"The popup control renders native popups from the shared code. This page demonstrates a variety of different techniques for displaying native popups.")
"The popup control renders native popups from the shared code. This page demonstrates a variety of different techniques for displaying native popups."),

new SectionModel(typeof(AutoFitLabelPage), "AutoFitLabel",
"A label that adjusts font size according of the label`s size.")
};
}
}
Loading