<UserControl
    x:Class="Microsoft.PowerToys.Settings.UI.Controls.QuickAccessList"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Microsoft.PowerToys.Settings.UI.Controls"
    xmlns:tkcontrols="using:CommunityToolkit.WinUI.Controls"
    xmlns:tkconverters="using:CommunityToolkit.WinUI.Converters">

    <UserControl.Resources>
        <tkconverters:BoolToVisibilityConverter
            x:Key="BoolToVisibilityConverter"
            FalseValue="Collapsed"
            TrueValue="Visible" />
        <tkconverters:StringVisibilityConverter x:Key="StringVisibilityConverter" />
    </UserControl.Resources>

    <ItemsControl ItemsSource="{x:Bind ItemsSource, Mode=OneWay}">
        <ItemsControl.ItemsPanel>
            <ItemsPanelTemplate>
                <tkcontrols:WrapPanel HorizontalAlignment="Stretch" VerticalSpacing="12" />
            </ItemsPanelTemplate>
        </ItemsControl.ItemsPanel>
        <ItemsControl.ItemTemplate>
            <DataTemplate x:DataType="local:QuickAccessItem">
                <local:FlyoutMenuButton
                    AutomationProperties.Name="{x:Bind Title}"
                    Command="{x:Bind Command}"
                    CommandParameter="{x:Bind CommandParameter}"
                    Visibility="{x:Bind Visible, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}">
                    <local:FlyoutMenuButton.Content>
                        <TextBlock
                            Style="{StaticResource CaptionTextBlockStyle}"
                            Text="{x:Bind Title}"
                            TextAlignment="Center"
                            TextWrapping="Wrap" />
                    </local:FlyoutMenuButton.Content>
                    <local:FlyoutMenuButton.Icon>
                        <Image>
                            <Image.Source>
                                <BitmapImage UriSource="{x:Bind Icon}" />
                            </Image.Source>
                        </Image>
                    </local:FlyoutMenuButton.Icon>
                    <ToolTipService.ToolTip>
                        <ToolTip Content="{x:Bind Description}" Visibility="{x:Bind Description, Converter={StaticResource StringVisibilityConverter}}" />
                    </ToolTipService.ToolTip>
                </local:FlyoutMenuButton>
            </DataTemplate>
        </ItemsControl.ItemTemplate>
    </ItemsControl>
</UserControl>
