<ContentControl
    x:Class="PixiEditor.Zoombox.Zoombox"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:local="clr-namespace:PixiEditor.Zoombox"
    mc:Ignorable="d"
    x:Name="uc"
    d:DesignHeight="450"
    d:DesignWidth="800">
    <Canvas
        MouseDown="OnMouseDown"
        MouseUp="OnMouseUp"
        MouseMove="OnMouseMove"
        MouseWheel="OnScroll"
        ClipToBounds="True"
        IsManipulationEnabled="{Binding UseTouchGestures, ElementName=uc}"
        ManipulationDelta="OnManipulationDelta"
        ManipulationStarted="OnManipulationStarted"
        ManipulationCompleted="OnManipulationCompleted"
        x:Name="mainCanvas"
        Background="Transparent"
        SizeChanged="OnMainCanvasSizeChanged">
        <Grid
            x:Name="mainGrid"
            SizeChanged="OnGridSizeChanged"
            Canvas.Left="{Binding ElementName=uc, Path=CanvasX}"
            Canvas.Top="{Binding ElementName=uc, Path=CanvasY}">
            <Grid.RenderTransform>
                <TransformGroup>
                    <ScaleTransform
                        x:Name="scaleTransform"
                        ScaleX="{Binding ElementName=uc, Path=ScaleTransformXY}"
                        ScaleY="{Binding ElementName=uc, Path=ScaleTransformXY}" />
                    <RotateTransform
                        x:Name="rotateTransform"
                        Angle="{Binding ElementName=uc, Path=RotateTransformAngle}" />
                    <ScaleTransform
                        x:Name="flipTransform"
                        ScaleX="{Binding ElementName=uc, Path=FlipTransformX}"
                        ScaleY="{Binding ElementName=uc, Path=FlipTransformY}" />
                </TransformGroup>
            </Grid.RenderTransform>
            <ContentPresenter
                Content="{Binding AdditionalContent, ElementName=uc}" />
        </Grid>
    </Canvas>
</ContentControl>