<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:ctrl="clr-namespace:Elwig.Controls">
    <Style TargetType="ctrl:UnitTextBox" BasedOn="{StaticResource {x:Type TextBox}}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ctrl:UnitTextBox">
                    <Border x:Name="Border"
                            BorderThickness="{Binding Path=BorderThickness, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
                            BorderBrush="{Binding Path=BorderBrush, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}">
                        <Grid Background="{Binding Path=Background, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}">
                            <ScrollViewer x:Name="PART_ContentHost" VerticalAlignment="Bottom">
                                <ScrollViewer.Margin>
                                    <Binding ElementName="UnitBlock" Path="ActualWidth">
                                        <Binding.Converter>
                                            <ctrl:WidthToMarginConverter/>
                                        </Binding.Converter>
                                    </Binding>
                                </ScrollViewer.Margin>
                            </ScrollViewer>
                            <TextBlock x:Name="UnitBlock" Text="{Binding Path=Unit, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
                                       FontSize="10" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="3"/>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="Border" Property="BorderBrush" Value="LightGray"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="TextAlignment" Value="Right"/>
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="UseLayoutRounding" Value="True"/>
        <Style.Triggers>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Foreground" Value="Gray"/>
            </Trigger>
        </Style.Triggers>
    </Style>
</ResourceDictionary>
