【发布时间】:2015-10-16 12:44:41
【问题描述】:
我已将我的 WPF 窗口设置为最大化,但是其中的项目(例如按钮和图像)有时会与窗口一起拉伸,甚至位置错位。
<Window x:Class="HelloApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="HelloApp" Height="661.842" Width="1105.263"
WindowStyle="None" ResizeMode="NoResize"
WindowStartupLocation="CenterScreen" WindowState="Maximized">
<Grid Background="#FFF3F3F3" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Height="Auto" Width="Auto">
<Label Content="Hello" HorizontalAlignment="Left" Margin="20,48,0,0" VerticalAlignment="Top" FontSize="36" FontFamily="Segoe UI Light"/>
<Image Margin="49,7,994,593" Source="Infinite_symbol__128.png"/>
<Button x:Name="exitBtn" Content="" HorizontalAlignment="Left" Margin="1042.148,9.606,0,0" VerticalAlignment="Top" Width="52.852" Height="51" BorderBrush="{x:Null}" Click="exitBtn_Click">
<Button.Background>
<ImageBrush ImageSource="close33 (2).png"/>
</Button.Background>
</Button>
</Grid>
</Window>
例如,如果按钮 X 在我启动程序时位于编辑器的左上角,它将保留在编辑器的左上角,但是最大化时实际的左上角会相距更远。
我希望你明白我的意思。我希望我的孩子项目与父母一起最大化。如何编辑我的代码来完成这项工作?
【问题讨论】:
-
将您的布局代码包括
container element、button、editor和...在这里,您的答案将基于您当前的窗口布局。当此处没有关于您的布局的任何必需信息时,其他人如何为您提供帮助?
标签: c# wpf wpf-controls expression-blend