0

メインウィンドウには以下があります

    <Window x:Uid="Window_1" x:Class="App1.MainWindow"  
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     
            Title="MainWindow" Height="350" Width="525" Loaded="Window_Loaded" Closing="Window_Closing" 
            SizeChanged="Window_SizeChanged" Topmost="True" AllowsTransparency="True"  Opacity="1"
            WindowStyle="None" ResizeMode="CanMinimize"  WindowStartupLocation="CenterScreen"   
            WindowState="Maximized" KeyDown="Window_KeyDown" MouseDoubleClick="Window_MouseDoubleClick"  Background="Black"
            MouseLeftButtonDown="Window_MouseLeftButtonDown" MouseMove="Window_MouseMove"  >

 <Viewbox x:Uid="Viewbox_1" Stretch="Uniform" StretchDirection="Both" SnapsToDevicePixels="True" >
        <Grid  x:Uid="MainLayout"   Name="MainLayout" SnapsToDevicePixels="True">
            <Canvas x:Uid="MainCanvas" Name="MainCanvas" SnapsToDevicePixels="True">

            </Canvas>
        </Grid>
    </Viewbox>

しかし、どういうわけか、ウィンドウのNORMALモードでは、いくつかのパディングが表示されます(ウィンドウの背景色のために黒です)

それを取り出す方法の手がかりはありますか?

ここに画像の説明を入力してください

4

2 に答える 2

2

ルート ウィンドウで:Background="Transparent"

于 2012-05-24T20:21:01.817 に答える
1

I tried to duplicate your problem, but without the full code, it doesn't seem to happen. I used this code:

<Window x:Class="WpfApplication2.MainWindow"
        x:Uid="Window_1"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"      
            Title="MainWindow" Height="350" Width="525" Topmost="True" AllowsTransparency="True"  Opacity="1" 
            WindowStyle="None" ResizeMode="CanMinimize"  WindowStartupLocation="CenterScreen"  Background="Black" >


    <Grid Background="Green">
        <Viewbox x:Uid="Viewbox_1" Stretch="Uniform" StretchDirection="Both" SnapsToDevicePixels="True" >
            <Grid Background="Red"  x:Uid="MainLayout"   Name="MainLayout" SnapsToDevicePixels="True">
                <Canvas x:Uid="MainCanvas" Name="MainCanvas" SnapsToDevicePixels="True" Background="Blue">

                </Canvas>
            </Grid>
        </Viewbox>

    </Grid>
</Window>

Just to see what would happen. Obviously without the image, the inner canvas, grid and viewbox don't take up any space and so all you get is a solid Green window (with the Green from the main Grid completely overlapping the Black of the Window).

My only thought is: Could it have something to do with the aspect ratio of your image versus the aspect ratio of your window when the Viewbox is using Uniform stretching?

于 2012-05-23T19:21:09.290 に答える