shuhelohelo’s blog

Xamarin.Forms多めです.

Xamarin.FormsのLabelは色々できることを知った

docs.microsoft.com

Labelに収まらない文字列を「...」で省略する3種類のTruncationがとても便利.

f:id:shuhelohelo:20200315231212p:plain

        <StackLayout>
            <Frame
                HorizontalOptions="Center"
                VerticalOptions="Center"
                WidthRequest="200">
                <Label Text="何も指定しない場合は,テキストは折り返される." />
            </Frame>
            <Frame
                HorizontalOptions="Center"
                VerticalOptions="Center"
                WidthRequest="200">
                <Label LineBreakMode="TailTruncation" Text="Truncationを指定すると,収まらない分は「...」で省略される." />
            </Frame>
            <Frame
                HorizontalOptions="Center"
                VerticalOptions="Center"
                WidthRequest="200">
                <Label LineBreakMode="HeadTruncation" Text="Truncationを指定すると,収まらない分は「...」で省略される." />
            </Frame>
            <Frame
                HorizontalOptions="Center"
                VerticalOptions="Center"
                WidthRequest="200">
                <Label LineBreakMode="MiddleTruncation" Text="Truncationを指定すると,収まらない分は「...」で省略される." />
            </Frame>
        </StackLayout>