日期:2014-05-17  浏览次数:21007 次

WPF,请教TabControl控件

<Grid>
    <TabControl Name="tabcontrol1" BorderBrush="Red" Margin="0,0,521,294">
        <TabItem Header="第一个选项卡" Height="30" />
        <TabItem Header="第二个选项卡" Height="30"></TabItem>
    </TabControl>
    <Button Content="Button" HorizontalAlignment="Left" Margin="295,249,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click_1"/>
</Grid>




设计的时候,明明Button是在TabControl外面,编译之后,为什么Button却是在TabControl里面了呢?

------解决方案--------------------
TabControl的定位有问题,你使用了四周定位,却没有设置TabControl的宽高,这样实际运行的时候,由于窗口肯定比设计的时候大,那么TabControl的宽高就比设计时大,Button自然就跑里面去了。