HandyControl
HandyControl copied to clipboard
自定义 TabItem 时候提示 ”无法找到名为“HandyControl.Controls.TabItem”的资源“
Describe the bug
自定义TabItem样式的时候使用BaseOn"{StaticResource {x:Type hc:TabItem}}"找不到HandyControl.Controls.TabItem, 不知道为什么,3.2.0是可以的,3.3.0就不行了
Steps to reproduce the bug
下面是自定义的样式:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:hc="https://handyorg.github.io/handycontrol" xmlns:interactivity="https://handyorg.github.io/handycontrol">
<Style x:Name="IconTabItem" TargetType="BAC:IconTabItem" BasedOn="{StaticResource {x:Type hc:TabItem}}">
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="Background" Value="#FF033776" />
<Setter Property="Foreground" Value="#FFBFCBD9" />
<Setter Property="BorderThickness" Value="1,0,1,1" />
<Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}" />
<Setter Property="Margin" Value="0" />
<Setter Property="Padding" Value="10,0,0,0" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Stretch" />
<Setter Property="Menu" Value="{StaticResource TabItemMenu}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="BAC:IconTabItem">
<Grid x:Name="templateRoot" Cursor="Hand" SnapsToDevicePixels="true" ContextMenu="{TemplateBinding Menu}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Border Grid.ColumnSpan="3" BorderThickness="{TemplateBinding BorderThickness}" x:Name="mainBorder" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" Margin="0">
<Border Margin="0,0,0,-1" x:Name="innerBorder" Background="{DynamicResource RegionBrush}" Visibility="Collapsed" />
</Border>
<ContentControl Margin="10,0,0,0" Grid.Column="0" Name="PresenterIcon">
<ContentPresenter ContentSource="Icon" HorizontalAlignment="Center" VerticalAlignment="Center" />
</ContentControl>
<ContentPresenter Grid.Column="1" x:Name="contentPresenter" ContentSource="Header" Focusable="False" HorizontalAlignment="Stretch" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="Center" />
<Border Name="BorderMask" Grid.Column="1" HorizontalAlignment="Right" Width="20" Background="{TemplateBinding Background}" Margin="0,0,1,1">
<Border.OpacityMask>
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
<GradientStop Color="White" Offset="1" />
<GradientStop Offset="0" />
</LinearGradientBrush>
</Border.OpacityMask>
</Border>
<Button Grid.Column="2" Focusable="False" Command="interactivity:ControlCommands.Close" Visibility="{TemplateBinding ShowCloseButton,Converter={StaticResource Boolean2VisibilityConverter}}" Background="Transparent" Style="{StaticResource ButtonCustom}" Width="28">
<Path x:Name="closeButton" Fill="{TemplateBinding Foreground}" Width="8" Height="8" Style="{StaticResource ClosePathStyle}" />
</Button>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="true">
<Setter Property="Panel.ZIndex" Value="1" />
<Setter Property="Visibility" TargetName="innerBorder" Value="Visible" />
<Setter Property="Background" TargetName="BorderMask" Value="{DynamicResource RegionBrush}" />
<Setter Property="TextBlock.Foreground" TargetName="contentPresenter" Value="#FF000000" />
<Setter Property="Fill" TargetName="closeButton" Value="#FF000000" />
</Trigger>
<Trigger Property="Icon" Value="{x:Null}">
<Setter Property="Visibility" Value="Collapsed" TargetName="PresenterIcon" />
</Trigger>
<Trigger Property="ShowCloseButton" Value="True">
<Setter Property="Margin" Value="0,0,0,1" TargetName="BorderMask" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Opacity" Value="0.4" TargetName="contentPresenter" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Expected behavior
No response
Screenshots
No response
NuGet package version
HandyControl 3.3.0
IDE
Visual Studio 2019
Framework type
.Net Framework 4.7.2
Windows version
Windows 10