C# 为什么这些WPF元素没有完全显示出来?
我用C#编写了一个程序,它使用了使用WPF开发的用户界面,标记用XAML。 但是,当我启动应用程序窗口时 这种情况经常发生 但是,当我最大化窗口时 这种情况经常发生 似乎我的按钮不是在显示画布上正确绘制(?),就是没有正确渲染(?) 这个问题应该如何解决?(按钮的显示方式必须与后一幅图像中的显示方式相同,即使窗口平铺时也是如此。) (该程序是使用Visual Studio 2015和DotNet 4.5.2构建的) 更新:我忘了为窗口添加XAML代码-所以它在这里C# 为什么这些WPF元素没有完全显示出来?,c#,wpf,visual-studio-2015,C#,Wpf,Visual Studio 2015,我用C#编写了一个程序,它使用了使用WPF开发的用户界面,标记用XAML。 但是,当我启动应用程序窗口时 这种情况经常发生 但是,当我最大化窗口时 这种情况经常发生 似乎我的按钮不是在显示画布上正确绘制(?),就是没有正确渲染(?) 这个问题应该如何解决?(按钮的显示方式必须与后一幅图像中的显示方式相同,即使窗口平铺时也是如此。) (该程序是使用Visual Studio 2015和DotNet 4.5.2构建的) 更新:我忘了为窗口添加XAML代码-所以它在这里 <Window x:Cl
<Window x:Class="NKryptorTester_WPF.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:NKryptorTester_WPF"
mc:Ignorable="d"
Title="NKryptor Desktop" Height="600" Width="1024">
<Grid>
<Button x:Name="ButtonSignup" Click="ActionSignup" FontWeight="Light" Foreground="White" Content="Signup" BorderThickness="0" Height="50" Width="250" FontSize="20" Margin="385,240,381,279" Background="#FF21877E"/>
<Button x:Name="ButtonSignin" Click="ActionSignin" FontWeight="Light" Foreground="White" Content="Signin" BorderThickness="0" Height="50" Width="250" FontSize="20" Margin="385,290,381,229" Background="#FF712687"/>
</Grid>
你必须摆脱固定保证金,尝试这样做:
<Grid>
<StackPanel Orientation="Vertical" VerticalAlignment="Center">
<Button x:Name="ButtonSignup" Click="ActionSignup" FontWeight="Light" Foreground="White" Content="Signup" BorderThickness="0" Height="50" Width="250" FontSize="20" Background="#FF21877E"/>
<Button x:Name="ButtonSignin" Click="ActionSignin" FontWeight="Light" Foreground="White" Content="Signin" BorderThickness="0" Height="50" Width="250" FontSize="20" Background="#FF712687"/>
</StackPanel>
</Grid>
为添加的窗口添加Xaml。我之前忘了添加XAML代码。它几乎可以工作了。第一个按钮正确渲染。我正在努力使第二个按钮也能正常工作。根据你的风格,你可以设置一些固定的边距,也许只在第二个按钮上。很好,我很高兴这有帮助。