<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:behaviors="using:Bili.App.Behaviors"
    xmlns:controls="using:Bili.App.Controls"
    xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
    xmlns:loc="using:Bili.App.Resources.Extension"
    xmlns:local="using:Bili.App.Controls.Community">
    <Style x:Key="DefaultCommentMainViewStyle" TargetType="local:CommentMainView">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:CommentMainView">
                    <Grid RowSpacing="12">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="*" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <TextBlock
                                Style="{StaticResource SubtitleTextBlockStyle}"
                                Margin="12,0,0,0"
                                HorizontalAlignment="Left"
                                VerticalAlignment="Center"
                                FontSize="14"
                                Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.CurrentSort.Title}" />
                            <ComboBox
                                x:Name="OrderTypeComboBox"
                                Grid.Column="1"
                                MinWidth="100"
                                VerticalAlignment="Center"
                                ItemsSource="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.SortCollection}"
                                SelectedItem="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.CurrentSort}" />
                        </Grid>
                        <Grid Grid.Row="1">
                            <local:CommentRepeater ItemsSource="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.Items}" TopComment="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.TopComment}" />
                            <controls:OverlayLoadingPanel IsBarActive="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.IsIncrementalLoading}" IsRingActive="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.IsReloading}" />
                            <controls:ErrorPanel
                                ActionContent="{loc:Locale Name=Refresh}"
                                Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.ErrorText, Mode=OneWay}"
                                Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.IsError, Mode=OneWay}">
                                <interactivity:Interaction.Behaviors>
                                    <behaviors:ReloadBehavior />
                                </interactivity:Interaction.Behaviors>
                            </controls:ErrorPanel>
                            <controls:ErrorPanel
                                ActionContent="{loc:Locale Name=Refresh}"
                                Text="{loc:Locale Name=NoReply}"
                                Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.IsEmpty}">
                                <interactivity:Interaction.Behaviors>
                                    <behaviors:ReloadBehavior />
                                </interactivity:Interaction.Behaviors>
                            </controls:ErrorPanel>
                        </Grid>

                        <local:CommentBox
                            Grid.Row="2"
                            AllowFocusOnInteraction="True"
                            ReplyTip="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.ReplyTip}"
                            ResetSelectedCommand="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.ResetSelectedCommentCommand}"
                            SendCommand="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.SendCommentCommand}"
                            Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.ReplyText, Mode=TwoWay}"
                            Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.IsError, Converter={StaticResource BoolToVisibilityReverseConverter}}" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style BasedOn="{StaticResource DefaultCommentMainViewStyle}" TargetType="local:CommentMainView" />
</ResourceDictionary>
