Why can't I move a tab control in a WPF designer?

I have a ComboBox inside a tab, and I can resize, skew and rotate it with the mouse. However, when I want to move it, I am not allowed. To change the position of the combo box, I need to manually enter the coordinates into the fields of the field, which is very annoying. Why can't I just move it by dragging it with the mouse?

UPDATE

This actually happens only in the second tab. On the first tab, I can move the controls as expected. So I shortened and added part of the tab to my xaml file in order to reorder the tabs. Now I can move the controls in the first tab (the former second tab), while I can not move the controls in the second tab.

Sounds like a WPF designer bug to me ...

UPDATE 2

This is a simple test case. TestComboBox in the second tab cannot 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 order of the tabs, 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> 
+4
source share
3 answers

I had the same problem. Having solved it, placing TabControl inside the grid - see the 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> 
+2
source

I just tried adding TabControl to a new WPF application. I added two TabItem elements with a ComboBox in each. At first, Visual Studio allowed me to move the ComboBox to the first tab, but not the second.

After I moved the ComboBox to the second tab, it will return to its original position when I release the mouse button. On closer inspection, this happened because the first TabItem had a Grid , but not the second ... maybe you had a similar problem?

However, after testing the code that you just added, I'm afraid to say that I do not have the same problem as you. Perhaps you should restart Visual Studio, and perhaps even your computer?

0
source

I have the same problem when working with WPF, but I do this to get around it.

Just comment on the bars before what you work on.

I know that it hurts to do this when working with large projects, but this is the only way I have found.

0
source

Source: https://habr.com/ru/post/1498174/


All Articles