Después de reescribir TabControl, ya no se puede usar arrastrar y soltar.
No usé TabPanel en el estilo, porque no quiero que el título de TabItem se ajuste. Después de hacerlo, ya no se puede usar arrastrar y soltar.
Después de sobrescribir TabControl, la función de arrastrar y soltar ya no está disponible
No usé TabPanel en el estilo, porque no quería que el encabezado TabItem se ajustara, por lo que arrastrar y soltar no funcionará
<Style x:Key="DefaultTabControl" TargetType="{x:Type TabControl}">
<Setter Property="Padding" Value="5 0 5 0"/>
<Setter Property="Background" Value="Transparent" />
<Setter Property="HorizontalContentAlignment" Value="Left"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="BorderBrush" Value="{StaticResource ControlBorderBrush}" />
<Setter Property="ItemContainerStyle" Value="{DynamicResource FIconTabItemStyle}"/>
<Setter Property="TabStripPlacement" Value="Top"/>
<Setter Property="Panel.ZIndex" Value="3"/>
<Setter Property="local:ControlAttachProperty.HeaderHeight" Value="20"/>
<Setter Property="local:ControlAttachProperty.FocusBackground" Value="{StaticResource ButtonPressedBackground}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TabControl}">
<Grid x:Name="PART_Root" Margin="{TemplateBinding Margin}" >
<Grid.ColumnDefinitions>
<ColumnDefinition x:Name="col1" Width="Auto"/>
<ColumnDefinition x:Name="col2" Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition x:Name="row1" Height="Auto"/>
<RowDefinition x:Name="row2" Height="*"/>
</Grid.RowDefinitions>
<!--这里我没使用TabPanel,因为我不希望TabItem标题换行-->
<!--I'm not using a TabPanel here, because I don't want the TabItem header to wrap-->
<Grid x:Name="PART_Header">
<Border x:Name="PART_HeaderBorder" BorderBrush="{TemplateBinding local:ControlAttachProperty.FocusBackground}"
BorderThickness="0,0,0,2" Panel.ZIndex="{TemplateBinding Panel.ZIndex}"/>
<ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Disabled" Margin="{TemplateBinding Padding}" Panel.ZIndex="2" >
<StackPanel x:Name="PART_HeaderPanel" Orientation="Vertical" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
IsItemsHost="True" MinHeight="{TemplateBinding local:ControlAttachProperty.HeaderHeight}"/>
</ScrollViewer>
</Grid>
<Border x:Name="PART_ContentPanel" Grid.Column="1" BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}"
KeyboardNavigation.DirectionalNavigation="Contained" KeyboardNavigation.TabIndex="2"
KeyboardNavigation.TabNavigation="Local" Width="Auto">
<ContentPresenter x:Name="PART_SelectedContentHost" ContentSource="SelectedContent" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Width="Auto"/>
</Border>
</Grid>
@kwonganding ¿Puede crear una pequeña muestra que muestre su problema? gracias
muestra corta:
dragdrop-test.zip
Oye, tuve el mismo problema. La solución rápida es ajustar su ContentPresenter a AdornerDecorator.
Comentario más útil
Oye, tuve el mismo problema. La solución rápida es ajustar su ContentPresenter a AdornerDecorator.