Depois de reescrever TabControl, arrastar e soltar não pode mais ser usado.
Eu não usei TabPanel no estilo, porque não quero que o título TabItem seja quebrado. Depois de fazer isso, arrastar e soltar não pode mais ser usado.
Depois de sobrescrever TabControl, arrastar e soltar não está mais disponível
Eu não usei TabPanel no estilo porque não queria que o cabeçalho TabItem fosse quebrado, então arrastar e soltar não funcionaria
<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 Você pode criar uma pequena amostra que mostre seu problema? THX
amostra curta:
dragdrop-test.zip
Ei, eu tive o mesmo problema. A solução rápida é envolver seu ContentPresenter em AdornerDecorator.
Comentários muito úteis
Ei, eu tive o mesmo problema. A solução rápida é envolver seu ContentPresenter em AdornerDecorator.