对菜鸟问题表示歉意,
我的XAML学习之旅是从WPF开始的,并有以下窗口: 但运行时却是这样的: [下面标记]
我的标记中的什么原因导致了这种情况?我可以把窗口拉长,但我觉得这是作弊,我应该知道是什么原因导致真正理解 XAML/WPF..
另外,我一直在努力遵循良好的实践,任何有关“正确”编码实践的反馈将不胜感激:)谢谢你
标记:
<Window x:Class="xamlFun.NET8.NewTimeLine"
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"
mc:Ignorable="d"
ResizeMode="NoResize"
Title="NewTimeLineGrid" Height="223" Width="688" WindowStyle="ToolWindow">
<Border Padding="10" Margin="0,0,0,2">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="110*" />
<ColumnDefinition Width="105*"/>
<ColumnDefinition Width="110*"/>
<ColumnDefinition Width="150*"/>
<ColumnDefinition Width="150*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition Height="60"/>
<RowDefinition/>
</Grid.RowDefinitions>
<!---Col 0 Row 0-->
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Grid.Row="0" Grid.Column="0">
<Label Content="Start Time" Margin="0 5" />
<TextBox Name="txtStartTime" Height="20" Width="50" Margin="0 10" TabIndex="0" />
</StackPanel>
<!---Col 1 Row 0-->
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Grid.Row="0" Grid.Column="1">
<Label Content="Duration" Margin="0 5" />
<TextBox Name="txtDuration" Height="20" Width="50" Margin="0 10" TabIndex="1" />
</StackPanel>
<!---Col 2 Row 0-->
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Grid.Row="0" Grid.Column="2">
<Label Content="End Time" Margin="0 5" />
<TextBox Name="txtEndTime" Height="20" Width="50" Margin="0 10" TabIndex="2" />
</StackPanel>
<!---Col 3 Row 0-->
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Grid.Row="0" Grid.Column="3">
<Label Content="LogIT Call" Margin="0 5" />
<TextBox Name="txtLogit" Height="20" Width="80" Margin="0 10" TabIndex="3" />
</StackPanel>
<!---Col 4 Row 0-->
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Grid.Row="0" Grid.Column="4">
<Label Content="User" Margin="0 5" />
<TextBox Name="txtUser" Height="20" Width="100" Margin="0 10" TabIndex="3" />
</StackPanel>
<!---Col 0 Row 1-->
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3">
<Label Content="Client" Margin="0 5" />
<TextBox Name="txtClient" Height="20" Width="100" Margin="0 10" TabIndex="3" />
</StackPanel>
<!---Col 2 Row 1-->
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Grid.Row="1" Grid.Column="3" Grid.ColumnSpan="2">
<Label Content="Activiy" Margin="0 5" />
<TextBox Name="txtActivity" Height="20" Width="100" Margin="0 10" TabIndex="3" />
</StackPanel>
<!--Col 0 Row 2-->
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="5">
<Label Content="Note" Margin="0 5" />
<TextBox Name="txtNote" Height="40" Margin="0 10" TabIndex="3" Width="600" MaxLines="2" />
</StackPanel>
<!--Col 3 Row 3-->
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Grid.Row="3" Grid.Column="3" Grid.ColumnSpan="2" Margin="10">
<Button Name="btnSave" Click="btnSave_Click" Content="Save" Margin="5 0 5 0" Padding="15 0 15 0"></Button>
<Button Name="btnCancel" Click="btnCancel_Click" Content="Cancel" Margin="5 0 5 0" Padding="15 0 15 0"></Button>
</StackPanel>
</Grid>
</Border>
</Window>
我尝试过调整大小,这有效,但不是我想要的。我已经摆弄了填充、边距和其他类似的旋钮,但预览版和最终版之间的差异并不容易弄清楚..