为什么我不能在WPF设计器的选项卡中移动控件?

我在选项卡中有一个ComboBox,我可以用鼠标改变它的大小,倾斜和旋转.但是,当我想要移动它时,我不被允许.要改变组合框的位置,我必须手动输入边距字段中的坐标,这真的很烦人.为什么我不能通过用鼠标拖动它来简单地移动它?

UPDATE

这实际上只发生在第二个选项卡中.在第一个标签中,我可以按预期移动控件.
所以我在我的xaml文件中剪切并粘贴了标签部分,以便更改标签顺序.现在,我可以在第一个选项卡(前第二个选项卡)中移动控件,而我无法在第二个选项卡中移动控件.

对我来说听起来像WPF设计师的bug …

更新2

这是一个简单的测试用例.无法移动第二个选项卡中的TestComboBox.

<Window x:Class="MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Height="718" Width="728" Background="{DynamicResource {x:Static SystemColors.ControlLightBrushKey}}">
    <TabControl HorizontalAlignment="Left" VerticalAlignment="Top">
        <TabItem Header="TabItem">
            <Grid Margin="0,10,0,4" Height="639" Width="708">
            </Grid>
        </TabItem>
        <TabItem Header="TabItem" Height="23">

            <Grid Margin="0,10,0,4" Height="639" Width="708">
                <ComboBox x:Name="TestComboBox" HorizontalAlignment="Left" Margin="84,10,0,0" Width="217" VerticalAlignment="Top" Height="22"/>
            </Grid>

        </TabItem>
    </TabControl>
</Window>

更改Tab键顺序后,可以移动TestComboBox:

<Window x:Class="MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Height="718" Width="728" Background="{DynamicResource {x:Static SystemColors.ControlLightBrushKey}}">
    <TabControl HorizontalAlignment="Left" VerticalAlignment="Top">
        <TabItem Header="TabItem" Height="23">

            <Grid Margin="0,10,0,4" Height="639" Width="708">
                <ComboBox x:Name="TestComboBox" HorizontalAlignment="Left" Margin="84,10,0,0" Width="217" VerticalAlignment="Top" Height="22"/>
            </Grid>

        </TabItem>            
        <TabItem Header="TabItem">
            <Grid Margin="0,10,0,4" Height="639" Width="708">
            </Grid>
        </TabItem>
    </TabControl>
</Window>

最佳答案 我有同样的问题.通过将TabControl放在网格中来解决它 – 请参阅下面的代码.

<Window x:Class="MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Height="718" Width="728" Background="{DynamicResource {x:Static SystemColors.ControlLightBrushKey}}">
<Grid>    
<TabControl HorizontalAlignment="Left" VerticalAlignment="Top">
        <TabItem Header="TabItem" Height="23">

        <Grid Margin="0,10,0,4" Height="639" Width="708">
            <ComboBox x:Name="TestComboBox" HorizontalAlignment="Left" Margin="84,10,0,0" Width="217" VerticalAlignment="Top" Height="22"/>
        </Grid>

        </TabItem>            
        <TabItem Header="TabItem">
        <Grid Margin="0,10,0,4" Height="639" Width="708">
          <ComboBox x:Name="TestComboBox2" HorizontalAlignment="Left" Margin="84,10,0,0" Width="217"       VerticalAlignment="Top" Height="22"/>
            </Grid>
        </TabItem>
    </TabControl>
</Window>
点赞