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

时间:2022-04-13 01:26:58

I am making a full-screen c# application, with WPF. But my content is leaving my screen because i want the height and width of the application to be dynamic. This is my current test:

我正在使用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>

How can I make sure the content will stay at its place?

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

1 个解决方案

#1


0  

Try this solution...

尝试此解决方案......

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

使用ViewBox覆盖所有Windows控件....

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

#1


0  

Try this solution...

尝试此解决方案......

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

使用ViewBox覆盖所有Windows控件....

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