xceedsoftware / wpftoolkit

All the controls missing in WPF. Over 1 million downloads.
Other
3.87k stars 872 forks source link

ExtendedTabControl: NullReference when using Static style or BasedOn default TabControl style. #1250

Open hosaka opened 6 years ago

hosaka commented 6 years ago

Minimal example (I was using the Xceed LiveExplorer):

<Style x:Key="TestXceedStyle"
       TargetType="{x:Type xctk:ExtendedTabControl}"
       BasedOn="{StaticResource {x:Type TabControl}}">
<!-- ... -->
<xctk:ExtendedTabControl x:Name="_extendedTabControl" Grid.Row="1"
                         Style="{StaticResource TestXceedStyle}">

Also:

<!-- Works as one would expect -->
<TabControl Grid.Row="1" Style="{StaticResource {x:Type TabControl}}">
        <TabItem Header="123"/>
</TabControl>

<!-- Throws NullReference -->
<xctk:ExtendedTabControl x:Name="_extendedTabControl" Grid.Row="1"
                         Style="{StaticResource {x:Type TabControl}}">
        <TabItem Header="Jan-16">
            January 2016
        </TabItem>
<xctk:ExtendedTabControl/>

The NullRef is thrown from: > Xceed.Wpf.Toolkit.dll!Xceed.Wpf.Toolkit.ExtendedTabControl.UpdateTabPanelHorizontalLayout()

I would hazard a guess that something in the default TabControl style causes the Update function to get/set a Null property.

XceedBoucherS commented 6 years ago

Hi,

Thanks for reporting this. It will be fixed in v3.7.

In the meantime, if you have access to code, you can go in file : Xceed.Wpf.Toolkit/ExtendedTabControl/Implementation/ExtendedTabControl.cs at the beginning of methods : UpdateTabPanelHorizontalLayout() and UpdateTabPanelHorizontalLayout() Add : if( _scrollViewer == null ) return;