<UserControl x:Class="Deployer.Raspberry.Gui.Views.Parts.LogPart"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800">
    <Grid>
        <ListView DataContext="{Binding Source={StaticResource Locator}, Path=OngoingOperationViewModel}" ItemsSource="{Binding Events}"
                  ToolTip="For a full detailed log, check inside the Logs folder of this tool">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Message}" />
                </DataTemplate>
            </ListView.ItemTemplate>

            <ListView.Style>
                <Style TargetType="ListView" BasedOn="{StaticResource {x:Type ListView}}">
                    <Style.Triggers>
                        <!-- ReSharper disable once Xaml.BindingWithContextNotResolved -->
                        <DataTrigger
                            Binding="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=Items.Count}"
                            Value="0">
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate>
                                        <TextBlock>No items to display</TextBlock>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>

            </ListView.Style>
        </ListView>
        <Button DataContext="{Binding Source={StaticResource Locator}, Path=LogViewModel}" HorizontalAlignment="Right" VerticalAlignment="Bottom" Content="Open log folder" Command="{Binding OpenLogFolder}" />
    </Grid>

</UserControl>
