<UserControl
    x:Class="Bili.App.Controls.TrimTextBlock"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:icons="using:Richasy.FluentIcon.Uwp"
    xmlns:local="using:Bili.App.Controls"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    d:DesignHeight="300"
    d:DesignWidth="400"
    mc:Ignorable="d">

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <TextBlock
            x:Name="DisplayBlock"
            FontFamily="{x:Bind FontFamily, Mode=OneWay}"
            FontSize="{x:Bind FontSize, Mode=OneWay}"
            FontWeight="{x:Bind FontWeight, Mode=OneWay}"
            Foreground="{x:Bind Foreground, Mode=OneWay}"
            IsTextSelectionEnabled="True"
            IsTextTrimmedChanged="OnIsTextTrimmedChanged"
            LineHeight="24"
            MaxLines="{x:Bind MaxLines, Mode=OneWay}"
            Text="{x:Bind Text, Mode=OneWay}"
            TextWrapping="Wrap" />
        <Button
            x:Name="OverflowButton"
            Grid.Row="1"
            Padding="2"
            BorderThickness="0"
            Visibility="Collapsed">
            <icons:RegularFluentIcon FontSize="12" Symbol="MoreHorizontal16" />
            <Button.Flyout>
                <Flyout>
                    <TextBlock
                        MaxWidth="320"
                        IsTextSelectionEnabled="True"
                        LineHeight="24"
                        Text="{x:Bind Text, Mode=OneWay}"
                        TextWrapping="Wrap" />
                </Flyout>
            </Button.Flyout>
        </Button>
    </Grid>
</UserControl>
