Reputation: 4676
I have a ComboBox within a tab and I can change its size, skew and rotation with the mouse. However, when I want to move it around, I'm not allowed to. To change the combobox's position, I have to manually enter the coordinates in the margin fields, which is really annoying. Why can't I simply move it by dragging it with the mouse?
UPDATE
This actually happens only in a second tab. In the first tab I can move around controls like expected. So I cut&pasted the tab part in my xaml file in order to change the tab order. Now, I can move around controls in the first tab (former 2nd tab) whereas I can't move controls in the 2nd tab.
Sounds like a WPF designer bug to me...
UPDATE 2
This is a simple test case. The TestComboBox in the 2nd tab can't be moved.
<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>
After changing the tab order, TestComboBox can be moved:
<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>
Upvotes: 4
Views: 4467
Reputation: 21
I had the same problem. Solved it by placing the the TabControl inside a grid - see code below.
<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>
Upvotes: 2
Reputation: 1256
I have the same problem while working with WPF, but i do this to "bypass" it.
Just comment the grids before the one you'll be working on.
I know that that is painfull to do when working with large projects, but it's the only way i have found.
Upvotes: 0
Reputation: 69987
I just tried adding a TabControl
into a new WPF Application. I added two TabItem
controls with a ComboBox
in each. At first, Visual Studio allowed me to move the ComboBox
in the first tab, but not the second.
After I moved the ComboBox
in the second tab, it would jump back to its original position when I let go of the mouse button. On closer inspection, this was because there was a Grid
in the first TabItem
, but not the second... perhaps you had a similar problem?
However, after testing the code that you just added, I'm afraid to say that I don't have the same problem that you do. Perhaps you should restart Visual Studio and maybe even your computer?
Upvotes: 0