更新时间:2023-10-11 15:11:16
将默认的工具提示样式放置在单独的程序集中的共享ResourceDictionary中,将允许它被多个项目使用.您可以使用以下方法将SharedStyleLibrary.dll的Resources文件夹中的MyDefaultStyles ResourceDictionary合并到App.xaml中:
Placing the default ToolTip Style in a shared ResourceDictionary in a separate assembly will allow it to be used by multiple projects. You can merge in the MyDefaultStyles ResourceDictionary in the Resources folder of the SharedStyleLibrary.dll into App.xaml using:
<App.Resources>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/SharedStyleLibrary;component/Resources/MyDefaultStyles.xaml"/>
</ResourceDictionary.MergedDictionaries>
</App.Resources>
如果MyDefaultStyles包含隐式工具提示样式(<Style TargetType="{x:Type ToolTip}">
),它将用作默认值.您还可以通过将样式指定为x:Key,然后在想要应用的任何范围(即窗口,用户控件,单个布局面板)中创建隐式工具提示样式,来更局部地定位它:
If MyDefaultStyles contains an implicit ToolTip Style (<Style TargetType="{x:Type ToolTip}">
) it will be used as the default. You can also target it more locally by instead giving the Style an x:Key and then creating an implicit ToolTip Style in whatever scope you want it to apply (i.e. Window, UserControl, single layout Panel):
<Style TargetType="{x:Type ToolTip}" BasedOn="{StaticResource ExternalLibraryNamedStyle}">...