我正在使用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>
如何确保内容保留在原位?
答案 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>