我的内容离开了我的屏幕,我该如何防止这种情况?

时间:2016-04-04 13:54:45

标签: c# wpf xaml

我正在使用WPF制作全屏c#应用程序。 但我的内容是离开我的屏幕,因为我希望应用程序的高度和宽度是动态的。 这是我目前的测试:

<Window x:Class="examen.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:examen"
    mc:Ignorable="d"
    Background="#024886"
    Title="MainWindow" WindowStyle="None" WindowState="Maximized" >
    <Canvas>
        <Rectangle Fill="#FBB510" Height="84" RadiusX="20" RadiusY="20" Stroke="Black"
            VerticalAlignment="Bottom" MouseLeftButtonDown="Rectangle_MouseLeftButtonDown"
            Canvas.Left="248" Width="89" Canvas.Top="242"/>
    </Canvas>
</Window>

如何确保内容保留在原位?

1 个答案:

答案 0 :(得分:0)

Try this solution...

Suround all of your windows controls with a ViewBox....

    <Viewbox>

        <Canvas>
            <Rectangle Fill="#FBB510" Height="84" RadiusX="20" RadiusY="20" Stroke="Black" VerticalAlignment="Bottom" MouseLeftButtonDown="Rectangle_MouseLeftButtonDown" Canvas.Left="248" Width="89" Canvas.Top="242"/>
         </Canvas>

    </Viewbox>