<UserControl
  x:Class="Ocr.Gui.Controls.ImageControl"
  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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  xmlns:converters="clr-namespace:Ocr.Gui.Converters"
  xmlns:controls="clr-namespace:Ocr.Gui.Controls"
  d:DataContext="{d:DesignInstance controls:ImageControl}"
  d:DesignHeight="450"
  d:DesignWidth="800"
  mc:Ignorable="d">
  <UserControl.Resources>
    <converters:ImageConverter x:Key="Converter.CImage" />

    <ControlTemplate x:Key="ControlTemplate.ImageControl.Default" TargetType="controls:ImageControl">
      <Border DataContext="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}"
              Padding="4"
              HorizontalAlignment="Stretch"
              VerticalAlignment="Stretch">
        <Image RenderOptions.BitmapScalingMode="NearestNeighbor"
               Stretch="Uniform"
               Source="{Binding Image, Converter={StaticResource Converter.CImage}}" />
      </Border>
    </ControlTemplate>

    <Style x:Key="Style.ImageControl.Default" TargetType="controls:ImageControl">
      <Setter Property="Template" Value="{StaticResource ControlTemplate.ImageControl.Default}" />
    </Style>

    <Style BasedOn="{StaticResource Style.ImageControl.Default}" TargetType="controls:ImageControl" />
  </UserControl.Resources>
  <Grid />
</UserControl>