我在单独的 xaml 文件中有自定义注释,我想使用来自选定图表主题的画笔。我有两点:
我正在尝试按如下方式访问 TextAnnotationForeground Brush(此处使用 SciChart 论坛中的示例):
<s:CustomAnnotation x:Class="Charts.SciCharts.MarkerAnnotation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="http://schemas.abtsoftware.co.uk/scichart" VerticalAnchorPoint="Top" HorizontalAnchorPoint="Center" Margin="0"> <s:CustomAnnotation.Template> <ControlTemplate TargetType="s:CustomAnnotation"> <Border> <Viewbox> <StackPanel> <Path Data="m 4 14 4 0 0 -8 3 0 -5 -5 -5 5 3 0 z" Fill="#571CB61C" Stroke="#FF00B400" StrokeThickness="1" HorizontalAlignment="Center"/> <Border Margin="5" Padding="5 0 5 2" BorderThickness="1" BorderBrush="#FF00B400" Background="#571CB61C" CornerRadius="5" HorizontalAlignment="Center"> <TextBlock FontSize="12" Text="{Binding Label}" Foreground="{s:ThemeBinding TextAnnotationForeground}"/> </Border> </StackPanel> </Viewbox> </Border> </ControlTemplate> </s:CustomAnnotation.Template> </s:CustomAnnotation>
而且我在设计时和运行时都有错误:
Inner exception: Not a dependency object
我怎么能做到?
- 我需要为我的一个自定义注释再定义一个画笔,并且这个画笔应该根据所选主题进行更改。那么我可以在自定义主题 ResourceDictionary 中定义这个画笔并像第 1 点一样使用它吗?