Extra Space in ZoomPanel
I am using the ZoomPanel inside of a WPF UserControl. Following is my code:

<UserControl x:Class="Views.ZoomPanelViewer"
             Height="auto" Width="auto">
        <local:ByteArrayToBitmapConverter x:Key="ByteArrayToBitmapConverter"/>
        <DockPanel LastChildFill="True" Width="auto" Margin="2">
            <GroupBox Header="Crash Report Pages" DockPanel.Dock="Top" >
                    <ListView ItemsSource="{Binding Path=ListOfPages}" SelectedItem="{Binding Path=SelectedPage}">
                                <VirtualizingStackPanel Orientation="Horizontal">
                                <Border BorderThickness="1" CornerRadius="10" BorderBrush="Black">
                                    <Image Source="{Binding Path=ThumbnailPage}" Margin="2"></Image>
            <GroupBox  Header="Image Control" DockPanel.Dock="Top">
                        <RowDefinition Height="Auto"/>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                    <StackPanel Orientation="Horizontal"  VerticalAlignment="Top" HorizontalAlignment="Right">
                        <StackPanel Margin="10,0,0,0" VerticalAlignment="Top">
                            <Label Content="Rotation" />
                            <Slider Name="RotationSlider" Minimum="-180" Maximum="180" Width="200"
                                    Ticks="-180, -90, 0, 90, 180"
                                    IsSnapToTickEnabled="True" />
                        <StackPanel Orientation="Horizontal">
                            <ab2d:ZoomController Name="ZoomController1"  TargetZoomPanel="{Binding ElementName=ZoomPanel1}"/>
                            <TextBlock Name="testtb"/>
            <GroupBox Header="Selected Page" DataContext="{Binding Path=SelectedPage}" Width="auto" DockPanel.Dock="Left" Name="gbImage">
                <ab2d:ZoomPanel Name="ZoomPanel1"
                    IsAnimated="True"  IsPanningAnimated="False" VerticalAlignment="Top">
                    <Image x:Name="myImage" Source="{Binding Path=Page}" VerticalAlignment="Top"
                            <RotateTransform Angle="{Binding ElementName=RotationSlider, Path=Value}"></RotateTransform>

The issue I am having is with the GroupBox that has the ZoomPanel in it. As the code is above, when I open my application, the displayed image in the GroupBox has a lot of space between the top of the image and the GroupBox line. When I maximize the application the space goes away and the top of the image bumps up against the GroupBox line as desired. If I take the ZoomPanel out and leave the Image control and reopen the application, the top of the image bumps up against the GroupBox line when in a minimized and maximized mode. Any ideas what may be happening?
I do not have the images that are binded to your source code, but anyway I think I understand your problem.

The white space above and below the images is created when the aspect ration of the image is not the same as the aspect ration of the ZoomPanel.
For example if you are showing 300 x 100 image in a 300 x 300 ZoomPanel, the image will be shown in the center and above and below the image there would be for 100pt empty space (in case the default (0,0,1,1) Viewbox is used).

Unfortunately it is not possible to somehow set that the content of the ZoomPanel would be Top aligned - it is always centered.

I also find this very usual - for example in the drawing applications the image is usually centered to the center of the application and put to the top just below the toolbox.
Andrej Benedik

Forum Jump:

Users browsing this thread:
1 Guest(s)