<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:CustomTileImagePushPatternViewModel}">
        <Border Style="{DynamicResource ViewBorderStyle}">
            <Grid>                

                <HeaderedContentControl Width="Auto" VerticalAlignment="Top">
                    <HeaderedContentControl.Header>
                        <TextBlock Text="Tile Message" FontWeight="Bold" />
                    </HeaderedContentControl.Header>
                    <Grid>
                        <Border Grid.Column="1" Grid.Row="1" BorderThickness="5" BorderBrush="#FFDEDEDE" Width="Auto" Height="Auto" Background="#FF333333" HorizontalAlignment="Right" VerticalAlignment="Top">
                            <Grid Width="Auto" Height="Auto">
                                <Grid Width="173" Height="173">
                                    <i:Interaction.Behaviors>
                                        <behaviors:VisualBinderBehavior />
                                    </i:Interaction.Behaviors>
                                    <Image Source="{Binding TileBackground, Converter={StaticResource NullTileImageConverter}}" Stretch="UniformToFill" />
                                    <TextBlock HorizontalAlignment="Center" Margin="4,48,4,0" TextWrapping="Wrap" FontSize="{Binding TextSize}" Foreground="{Binding TextColors/}" Text="{Binding FreeText}" VerticalAlignment="Top"/>
                                    <Rectangle Fill="Transparent" Stroke="Black">
                                        <Rectangle.InputBindings>
                                            <MouseBinding MouseAction="LeftClick" Command="{Binding PickImageCommand}" />
                                        </Rectangle.InputBindings>
                                    </Rectangle>
                                </Grid>
                                <Grid x:Name="counter" HorizontalAlignment="Right" Height="30.733" Margin="0,12,12,0" VerticalAlignment="Top" Width="30.733">
                                    <Ellipse Fill="Black" HorizontalAlignment="Stretch" Height="Auto" Margin="0" Stroke="Black" VerticalAlignment="Stretch" Width="Auto" StrokeThickness="0"/>
                                    <TextBlock HorizontalAlignment="Center" Height="Auto" TextWrapping="Wrap" Text="{Binding Count}" VerticalAlignment="Stretch" Width="Auto" TextAlignment="Center" FontSize="21.333" d:LayoutOverrides="Height" Margin="0,-0.321,0,2.679"/>
                                </Grid>
                                <TextBlock Height="22" TextWrapping="NoWrap" Text="{Binding Title}" VerticalAlignment="Bottom" Margin="6,0,6,6" FontSize="18.667" FontWeight="Bold" Width="158" HorizontalAlignment="Center"/>
                                <TextBlock x:Name="ImageComment" HorizontalAlignment="Center" TextWrapping="Wrap" VerticalAlignment="Center" />
                            </Grid>
                        </Border>
                        <StackPanel Grid.Row="0" HorizontalAlignment="Stretch" Margin="0,0,187,0" d:LayoutOverrides="GridBox">
                            
                            <TextBlock TextWrapping="Wrap" Text="Free Text" Margin="4" />
                            <TextBox TextWrapping="Wrap" Margin="4" Text="{Binding FreeText, UpdateSourceTrigger=PropertyChanged}" />

                            <TextBlock TextWrapping="Wrap" Text="Text Size" Margin="4" />
                            <Slider Minimum="18" Maximum="32" IsSnapToTickEnabled="True" TickFrequency="2" AutoToolTipPlacement="BottomRight" Value="{Binding TextSize, UpdateSourceTrigger=PropertyChanged}" />

                            <TextBlock TextWrapping="Wrap" Text="Text Color" Margin="4" />
                            <ComboBox ItemsSource="{Binding TextColors}" SelectedIndex="0" IsSynchronizedWithCurrentItem="True">
                                <ComboBox.ItemTemplate>
                                    <DataTemplate>
                                        <DockPanel Height="36">
                                            <Rectangle Stroke="Black" StrokeThickness="0.5" Fill="{Binding FallbackValue=Transparent}" Width="120" Height="28" Margin="4" />
                                        </DockPanel>
                                    </DataTemplate>
                                </ComboBox.ItemTemplate>
                            </ComboBox>

                            <TextBlock TextWrapping="Wrap" Text="Count" Margin="4" />
                            <Slider Minimum="0" Maximum="99" IsSnapToTickEnabled="True" TickFrequency="1" AutoToolTipPlacement="BottomRight" Value="{Binding Count, UpdateSourceTrigger=PropertyChanged}" />

                            <TextBlock TextWrapping="Wrap" Text="Title" Margin="4" />
                            <TextBox TextWrapping="Wrap" Margin="4" Text="{Binding Title, UpdateSourceTrigger=PropertyChanged}" />
                            
                        </StackPanel>
                    </Grid>
                </HeaderedContentControl>

                <Button Content="Send" Height="Auto" Command="{Binding SendCommand}" VerticalAlignment="Bottom" d:LayoutOverrides="GridBox" Width="64" RenderTransformOrigin="2.643,1.088" HorizontalAlignment="Right" Margin="0,0,0,2.68" />
                
            </Grid>
        </Border>
        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding Count}" Value="0">
                <Setter TargetName="counter" Property="Visibility" Value="Hidden" />
            </DataTrigger>
            <DataTrigger Binding="{Binding TileBackground}" Value="{x:Null}">
                <Setter TargetName="ImageComment" Property="Text" Value="Click here to pick an image" />
            </DataTrigger>            
        </DataTemplate.Triggers>
    </DataTemplate>

</ResourceDictionary>