Search code examples
wpfxamlscreen-resolutionviewbox

Viewbox is clipping my dockpanel


this is what my program looks like in my editor

Editor Screen Shot

this is a screen shot from the tablet my program is running on.

Actual Screen Shot

The xaml for said code is this

<Window x:Class="DLIUnitLibrary_WPF.ConfigureWindowLandscape"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:DLIUnitLibrary_WPF"
        xmlns:posButton="clr-namespace:DLIUnitLibrary_WPF.Buttons"
        xmlns:UnitImagePanels="clr-namespace:DLIUnitLibrary_WPF.UnitImagePanels"
        Background="{DynamicResource formBackground}"
        Width="800"
        Height="480"
        WindowState="Maximized"
        WindowStyle="None"
        Loaded="Window_Loaded">
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Dictionary.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Window.Resources>
    <Viewbox Margin="10">
        <DockPanel x:Name="mainView"
                   Height="480"
                   Width="800">
            <local:DLIHeader DockPanel.Dock="Top"
                             Visibility="Hidden" />
            <WrapPanel Width="125"
                       ItemHeight="125"
                       ItemWidth="125"
                       Margin="0,5,0,0"
                       DockPanel.Dock="Right"
                       Orientation="Vertical"
                       VerticalAlignment="Bottom">
                <posButton:OposButton x:Name="msrButton"
                                      Margin="5"
                                      ImageSource="Images/msr_keymon.png" />
                <posButton:OposButton x:Name="imagerButton"
                                      Margin="5"
                                      ImageSource="Images/barcode_keymon.png" />
                <posButton:OposButton x:Name="brightButton"
                                      Margin="5"
                                      ImageSource="Images/brightness_keymon.png" />
            </WrapPanel>
            <Grid Margin="10">
                <Viewbox x:Name="tablet9viewbox"
                         Visibility="Hidden">
                    <UnitImagePanels:Tablet9Image />
                </Viewbox>
                <Viewbox x:Name="tablet7viewbox" Visibility="Hidden">
                    <UnitImagePanels:Tablet7Image>
                        <UnitImagePanels:Tablet7Image.LayoutTransform>
                            <TransformGroup>
                                <ScaleTransform />
                                <SkewTransform />
                                <RotateTransform Angle="90" />
                                <TranslateTransform />
                            </TransformGroup>
                        </UnitImagePanels:Tablet7Image.LayoutTransform>
                    </UnitImagePanels:Tablet7Image>
                </Viewbox>
            </Grid>
        </DockPanel>
    </Viewbox>
</Window>

The screen resolution on the tablet7 is 800x480. The tablet has a emulated 800x600 and when I up it to that I can see all 3 buttons.

The screen resolution on the tablet9 is 1024x768 and does not have the 2 button problem infact it renders it perfectly. What am I missing?

EDIT

I forgot about my code behind, sorry about that. It doesn't too to much on the OnLoadedevent, but it is here

private void Window_Loaded(object sender, RoutedEventArgs e)
{
    this.mainView.Height = System.Windows.SystemParameters.PrimaryScreenHeight;
    this.mainView.Width = System.Windows.SystemParameters.PrimaryScreenWidth;

    switch (DLIUnitFinder.GetDLIUnit())
    {
        case DLIUnit.tablet7:
            this.tablet7viewbox.Visibility = System.Windows.Visibility.Visible;
            break;
        case DLIUnit.tablet9:
            this.tablet9viewbox.Visibility = System.Windows.Visibility.Visible;
            break;
    }
}

Solution

  • For anyone else that is experiancing a similar problem it appears that Clipping is allowed with WrapPanel. I changed to the panel that has those 3 buttons in it from WrapPanel to UniformGrid and the buttons are now showing as they should.