<UserControl
    x:Class="LogoForceTestApp.Modules.MainModule.Views.LogPage"
    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:hc="https://handyorg.github.io/handycontrol"
    xmlns:local="clr-namespace:LogoForceTestApp.Modules.MainModule.Views"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:viewmodels="clr-namespace:LogoForceTestApp.Modules.MainModule.ViewModels"
    d:DataContext="{d:DesignInstance Type=viewmodels:LogPageViewModel}"
    d:DesignHeight="450"
    d:DesignWidth="800"
    mc:Ignorable="d">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="auto" />
            <RowDefinition />
            <RowDefinition Height="auto" />
        </Grid.RowDefinitions>
        <StackPanel Orientation="Horizontal">
            <hc:DatePicker
                Margin="4,0"
                hc:InfoElement.Title="选择开始时间"
                SelectedDate="{Binding SelectedStartDate}" />
            <hc:DatePicker
                Margin="4,0"
                hc:InfoElement.Title="选择结束时间"
                SelectedDate="{Binding SelectedEndDate}" />
            <Button
                Margin="4,0"
                VerticalAlignment="Bottom"
                Command="{Binding QueryCommand}"
                Content="查询" />
        </StackPanel>
        <DataGrid
            Grid.Row="1"
            AutoGenerateColumns="False"
            IsReadOnly="True"
            ItemsSource="{Binding LogModels}">
            <DataGrid.Columns>
                <DataGridTextColumn Binding="{Binding Id}" Header="ID" />
                <DataGridTextColumn Binding="{Binding Timestamp}" Header="时间" />
                <DataGridTextColumn Binding="{Binding Properties}" Header="日志" />
            </DataGrid.Columns>
        </DataGrid>
        <hc:Pagination
            Grid.Row="2"
            HorizontalAlignment="Center"
            IsJumpEnabled="True"
            MaxPageCount="{Binding MaxCount}"
            PageIndex="{Binding PageIndex}">
            <hc:Interaction.Triggers>
                <hc:EventTrigger EventName="PageUpdated">
                    <hc:EventToCommand Command="{Binding PageUpdatedCmd}" PassEventArgsToCommand="True" />
                </hc:EventTrigger>
            </hc:Interaction.Triggers>
        </hc:Pagination>
    </Grid>
</UserControl>