2013-08-21 18 views
4

我有一個選項卡內的組合框,我可以用鼠標更改它的大小,傾斜和旋轉。但是,當我想移動它時,我不被允許。要更改組合框的位置,我必須手動輸入邊距字段中的座標,這真的很煩人。爲什麼我不能簡單地通過拖動鼠標來移動它?爲什麼我無法在WPF設計器的選項卡中移動控件?

UPDATE

這實際上只在第二個選項卡發生。在第一個標籤中,我可以像預期的那樣移動控件。 所以我剪了&粘貼我的xaml文件中的選項卡部分以便更改選項卡順序。現在,我可以在第一個選項卡(前第二個選項卡)中移動控件,而我無法在第二個選項卡中移動控件。

聽起來像一個WPF設計錯誤,我...

更新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> 

更改選項卡訂單後,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> 
+0

適合我。如果可以的話,顯示你已經得到的xaml代碼可以顯示這個問題。 – Viv

回答

0

我只是想添加一個TabControl到一個新的WPF應用程序。我添加了兩個TabItem控件,每個控件都有一個ComboBox。起初,Visual Studio允許我在第一個選項卡中移動ComboBox,但不是第二個選項卡。

當我在第二個選項卡中移動ComboBox後,當我放開鼠標按鈕時,它會跳回原始位置。仔細觀察,這是因爲第一個TabItem中有一個Grid,但不是第二個......也許你有類似的問題?

但是,在測試剛添加的代碼之後,我不敢說我​​沒有和你一樣的問題。也許你應該重新啓動Visual Studio甚至你的電腦?

0

我在使用WPF時遇到同樣的問題,但我這樣做是爲了「繞過」它。

只是在你將要工作的網格之前發表評論。

我知道在處理大型項目時很難做到,但這是我找到的唯一方法。

2

我有同樣的問題。通過將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> 
相關問題