Viewbox正在剪切我的dockpanel

时间:2013-07-25 15:07:59

标签: wpf xaml screen-resolution viewbox

这是我的程序在我的编辑器中的样子

Editor Screen Shot

这是我运行程序的平板电脑的屏幕截图。

Actual Screen Shot

所述代码的xaml是这个

<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>

平板电脑7的屏幕分辨率为800x480。这款平板电脑有一个模拟的800x600,当我升级到它时,我可以看到所有3个按钮。

平板电脑9的屏幕分辨率为1024x768,没有2按钮问题,因为它完美呈现。我错过了什么?

修改

我忘记了我的代码,抱歉。它在OnLoadedevent上并没有太多,但它就在这里

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;
    }
}

1 个答案:

答案 0 :(得分:0)

对于正在尝试类似问题的其他人来说,WrapPanel允许剪辑。我从WrapPanelUniformGrid更改为其中包含3个按钮的面板,按钮现在显示为应有的。