这是我的代码
- XML code
<DockPanel Height="198" Margin="126,40,0,0" Name="dockPanel1" Width="303"> <Button DockPanel.Dock="Top" Content="Button" Height="23" Name="button1" Width="75" /> </DockPanel>
按理说按钮应该处于DockPanel控件的上端,但实际上它却处于中间,也就是说DockPanel.Dock="Top" 没有生效,请问这是怎么回事?
------解决方案--------------------
运行下这个看看
- XML code
<Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="200" Width="500"> <DockPanel> <Button DockPanel.Dock="Top" Content="Top Button" Height="23" Name="button1" Width="75"/> <Button DockPanel.Dock="Bottom" Content="Bottom Button" Height="23" Width="75" /> <Button DockPanel.Dock="Left" Content="Left Button" Height="23" Width="75" /> <Button DockPanel.Dock="Right" Content="Right Button" Height="23" Width="75"/> </DockPanel></Window>