I have custom annotation in separate xaml file and I want to use brushes from selected chart theme. I have two points:
I’m trying to access to TextAnnotationForeground Brush as follow (using example from SciChart forum here):
<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>
And I’ve got error both in design-time and run-time:
Inner exception: Not a dependency object
How could I make it?
- I need to define one more brush for one of my custom annotation, and this brush should changed according to selected theme. So could I define this brush in custom theme ResourceDictionary and use it the same as in point 1?