Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After I overwrote TabControl style, so drag-and-drop won't work (TabControl重写样式后不支持拖拽) #307

Open
kwonganding opened this issue Nov 28, 2018 · 4 comments
Labels

Comments

@kwonganding
Copy link

kwonganding commented Nov 28, 2018

我重写了TabControl后,拖拽不能使用了。
样式中我没使用TabPanel,因为我不希望TabItem标题换行,这样做了后拖拽不能使用了
After I overwrote TabControl, drag-and-drop is no longer available
I didn't use TabPanel in the style, because I didn't want the TabItem header to wrap, so drag-and-drop won't work

    <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 kwonganding changed the title TabControl重写样式后不支持拖拽 After I overwrote TabControl style, so drag-and-drop won't work (TabControl重写样式后不支持拖拽) Nov 28, 2018
@punker76
Copy link
Owner

@kwonganding Can you please create a short sample which shows your issue? thx

@kwonganding
Copy link
Author

kwonganding commented Dec 11, 2018

short sample:
dragdrop-test.zip

@punker76 punker76 added this to the 2.1.0 milestone Apr 22, 2019
@MichPal
Copy link

MichPal commented Jun 25, 2019

Hey, i had same issue. Quick fix is to wrap your ContentPresenter to AdornerDecorator.

@punker76 punker76 modified the milestones: 2.1.0, vNext Sep 25, 2019
@GuangZhouDekang
Copy link

Hey, i had same issue. Quick fix is to wrap your ContentPresenter to AdornerDecorator.

Can you give the demo for wrap the ContentPresenter to AdornerDecorator?

@punker76 punker76 removed this from the vNext milestone Sep 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants