<UserControl
    x:Class="Wallet.Avalonia.ItemView"
    xmlns="https://github.com/avaloniaui"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ui="using:FluentAvalonia.UI.Controls"
    xmlns:vm="using:Wallet"
    x:DataType="vm:ItemViewModel">
    <UserControl.Styles>
        <Style Selector="ui|SettingsExpander">
            <Setter Property="IsTabStop" Value="False" />
            <Setter Property="KeyboardNavigation.TabNavigation" Value="Local" />
        </Style>
    </UserControl.Styles>
    <Interaction.Behaviors>
        <AttachedBehaviour>
            <NavigateAction
                Region="{Binding Named, StringFormat='{}{0}:ContentHeader'}"
                Route="ItemCommandHeader"
                Scope="self" />
        </AttachedBehaviour>
        <DataTriggerBehavior
            Binding="{Binding State}"
            ComparisonCondition="Equal"
            Value="{x:Static vm:ItemState.Read}">
            <ConditionAction>
                <ConditionAction.Condition>
                    <ConditionalExpression ForwardChaining="And">
                        <ComparisonCondition LeftOperand="{Binding FromCategory}" RightOperand="True" />
                    </ConditionalExpression>
                </ConditionAction.Condition>
                <NavigateBackAction Region="Left" />
            </ConditionAction>
        </DataTriggerBehavior>
    </Interaction.Behaviors>
    <ScrollViewer Padding="12,0,12,0">
        <ItemsControl ItemTemplate="{ReflectionBinding Template}" ItemsSource="{Binding}">
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <StackPanel Spacing="24" />
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
        </ItemsControl>
    </ScrollViewer>
</UserControl>
