<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:vm="clr-namespace:WindowsPhone.Recipes.Push.Server.ViewModels"
                    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
                    xmlns:behaviors="clr-namespace:WindowsPhone.Recipes.Push.Server.Behaviors"
                    mc:Ignorable="d">

    <DataTemplate DataType="{x:Type vm:MessageStatusViewModel}">
        <DataTemplate.Resources>
            <Style x:Key="DefaultGridElementStyle" TargetType="{x:Type TextBlock}">
                <Setter Property="Padding" Value="15,3,0,3" />
            </Style>
        </DataTemplate.Resources>

        <Grid>
            <DataGrid ItemsSource="{Binding Status}"
                  AutoGenerateColumns="False"
                  IsReadOnly="True"
                  SelectionMode="Single"
                  SelectionUnit="FullRow"
                  CanUserResizeRows="False"
                  HeadersVisibility="Column"
                  BorderThickness="2"
                  BorderBrush="{StaticResource ViewBackgroundBrush}"
                  GridLinesVisibility="None"
                  AlternatingRowBackground="#FF535353"
                  RowDetailsVisibilityMode="VisibleWhenSelected"
				  Background="{DynamicResource ViewBackgroundBrush}"
				  Foreground="{DynamicResource ViewTextBrush}"
				  RowBackground="#FF424242" ColumnHeaderStyle="{DynamicResource DataGridColumnHeaderStyle}" CellStyle="{DynamicResource DataGridCellStyle}">

                <DataGrid.Columns>

                    <DataGridTextColumn Header="Pattern" Binding="{Binding Pattern, Mode=OneTime}" ElementStyle="{StaticResource DefaultGridElementStyle}" />

                    <DataGridTextColumn Header="Message" Binding="{Binding MessageType, Mode=OneTime}" ElementStyle="{StaticResource DefaultGridElementStyle}" />

                    <DataGridTemplateColumn Header="Status">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <StackPanel Margin="15,0,0,0" VerticalAlignment="Center" Orientation="Horizontal">
                                    <Ellipse x:Name="indicator" VerticalAlignment="Center" Margin="0,0,6,0" Width="6" Height="6" Fill="Red" />
                                    <TextBlock VerticalAlignment="Center" Text="{Binding StatusCode, Mode=OneTime}" />
                                </StackPanel>
                                <DataTemplate.Triggers>
                                    <DataTrigger Binding="{Binding StatusCode}" Value="OK">
                                        <Setter TargetName="indicator" Property="Fill" Value="LightGreen" />
                                    </DataTrigger>
                                </DataTemplate.Triggers>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>

                    <DataGridTemplateColumn Header="Connection">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <StackPanel Margin="15,0,0,0" VerticalAlignment="Center" Orientation="Horizontal">
                                    <Ellipse x:Name="indicator" VerticalAlignment="Center" Margin="0,0,6,0" Width="6" Height="6" />
                                    <TextBlock VerticalAlignment="Center" Text="{Binding DeviceConnectionStatus, Mode=OneTime}" />
                                </StackPanel>
                                <DataTemplate.Triggers>
                                    <DataTrigger Binding="{Binding DeviceConnectionStatus}" Value="Connected">
                                        <Setter TargetName="indicator" Property="Fill" Value="LightGreen" />
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding DeviceConnectionStatus}" Value="TempDisconnected">
                                        <Setter TargetName="indicator" Property="Fill" Value="Red" />
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding DeviceConnectionStatus}" Value="Inactive">
                                        <Setter TargetName="indicator" Property="Fill" Value="Gray" />
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding DeviceConnectionStatus}" Value="NotApplicable">
                                        <Setter TargetName="indicator" Property="Fill" Value="Black" />
                                    </DataTrigger>
                                </DataTemplate.Triggers>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>

                    <DataGridTemplateColumn Header="Subscription">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <StackPanel Margin="15,0,0,0" VerticalAlignment="Center" Orientation="Horizontal">
                                    <Ellipse x:Name="indicator" VerticalAlignment="Center" Margin="0,0,6,0" Width="6" Height="6" />
                                    <TextBlock VerticalAlignment="Center" Text="{Binding SubscriptionStatus, Mode=OneTime}" />
                                </StackPanel>
                                <DataTemplate.Triggers>
                                    <DataTrigger Binding="{Binding SubscriptionStatus}" Value="Active">
                                        <Setter TargetName="indicator" Property="Fill" Value="LightGreen" />
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding SubscriptionStatus}" Value="Expired">
                                        <Setter TargetName="indicator" Property="Fill" Value="Red" />
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding SubscriptionStatus}" Value="NotApplicable">
                                        <Setter TargetName="indicator" Property="Fill" Value="Black" />
                                    </DataTrigger>
                                </DataTemplate.Triggers>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>

                    <DataGridTemplateColumn Header="Notification">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <StackPanel Margin="15,0,0,0" VerticalAlignment="Center" Orientation="Horizontal">
                                    <Ellipse x:Name="indicator" VerticalAlignment="Center" Margin="0,0,6,0" Width="6" Height="6" />
                                    <TextBlock VerticalAlignment="Center" Text="{Binding NotificationStatus, Mode=OneTime}" />
                                </StackPanel>
                                <DataTemplate.Triggers>
                                    <DataTrigger Binding="{Binding NotificationStatus}" Value="Received">
                                        <Setter TargetName="indicator" Property="Fill" Value="LightGreen" />
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding NotificationStatus}" Value="QueueFull">
                                        <Setter TargetName="indicator" Property="Fill" Value="Red" />
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding NotificationStatus}" Value="Suppressed">
                                        <Setter TargetName="indicator" Property="Fill" Value="Gray" />
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding NotificationStatus}" Value="Dropped">
                                        <Setter TargetName="indicator" Property="Fill" Value="Gray" />
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding NotificationStatus}" Value="NotApplicable">
                                        <Setter TargetName="indicator" Property="Fill" Value="Black" />
                                    </DataTrigger>
                                </DataTemplate.Triggers>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>

                </DataGrid.Columns>

                <DataGrid.RowDetailsTemplate>
                    <DataTemplate>
                        <StackPanel Margin="2" Background="#FF2A2A2A">

                            <StackPanel Margin="1">
                                <TextBlock FontWeight="Bold" Margin="0,0,0,1" Text="Time Stamp" />
                                <TextBlock Text="{Binding Timestamp, Mode=OneTime, StringFormat=G}" />
                            </StackPanel>

                            <StackPanel Margin="1">
                                <TextBlock FontWeight="Bold" Margin="0,0,0,1" Text="Message Id" />
                                <TextBlock Text="{Binding MessageId, Mode=OneTime}" />
                            </StackPanel>

                            <StackPanel Margin="1">
                                <TextBlock FontWeight="Bold" Margin="0,0,0,1" Text="Channel URI" />
                                <TextBlock Text="{Binding ChannelUri, Mode=OneTime}" />
                            </StackPanel>

                        </StackPanel>
                    </DataTemplate>
                </DataGrid.RowDetailsTemplate>

            </DataGrid>
        </Grid>
    </DataTemplate>

</ResourceDictionary>