C# 用visualc处理布局问题
我正在Visual Studio 2017 Visual C上创建一个简单的WPF应用程序。 我有以下表格:C# 用visualc处理布局问题,c#,visual-studio,xaml,grid,visual-studio-2017,C#,Visual Studio,Xaml,Grid,Visual Studio 2017,我正在Visual Studio 2017 Visual C上创建一个简单的WPF应用程序。 我有以下表格: <Window x:Class="HelloWPFApp.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:
<Window x:Class="HelloWPFApp.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:HelloWPFApp"
mc:Ignorable="d"
Title="Greetings" Height="350" Width="525">
<Grid Height="319" VerticalAlignment="Bottom">
<Grid.RowDefinitions>
<RowDefinition Height="192*"/>
<RowDefinition Height="41*"/>
<RowDefinition Height="86*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock HorizontalAlignment="Center" TextWrapping="Wrap" Text="Select a message option and then choose the Display button." VerticalAlignment="Center" Height="16" Width="329" Margin="102,131,86,45"/>
<RadioButton x:Name="rbHello" Content="Hello" HorizontalAlignment="Left" Margin="102,2,0,0" VerticalAlignment="Top" Height="15" Width="47" Grid.Row="1"/>
<RadioButton x:Name="rbGoodbye" Content="Goodbye" HorizontalAlignment="Left" Margin="337,2,0,0" VerticalAlignment="Top" Height="15" Width="67" Grid.Row="1"/>
<Button Content="Display" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" Margin="231,2,0,0" Click="Button_Click" Height="20" Grid.Row="2"/>
</Grid>
</Window>
这是预览:
当我编译时,这是一个窗口中的结果
如果我尝试使用全屏显示,它会显示以下内容:
为什么会这样?我如何解决它?
这是一个例子 这是WPF而不是windows窗体。你的定位完全错了。当你拖放东西时,它使用绝对定位。如果你想把它放在中间,就用
但这是开始学习系统的好地方这看起来像WPF,而不是WinForms。您提供的链接是指向WPF示例的。对不起,WPF是正确的,我有点困惑。谢谢,非常有用