This is a migrated thread and some comments may be shown as answers.

AnnotationsProvider's problem...

3 Answers 132 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Dmitry
Top achievements
Rank 1
Dmitry asked on 03 Nov 2017, 12:51 PM

Hi. I was trying to run example code about 'AnnotationsProvider' feature from here:

https://github.com/telerik/xaml-sdk/tree/master/ChartView/WPF/AnnotationsProvider

However, it seems to me that it doesn't working as was supposed. Neither 'AnnotationDescriptor' or 'AnnotationDescriptorSelector' user control are not working properly (I had not seen any annotations at all). Only 'AnnotationCreated' user control drew the annotations by using code-behind event handler. What am i doing wrong?

My current Telerik libraries version is 2017.2.503.4

3 Answers, 1 is accepted

Sort by
0
Dmitry
Top achievements
Rank 1
answered on 04 Nov 2017, 05:18 AM

I forgot to mention that I've made some modifications in project itself. I switched to the NoXaml dll's as well as explicitly included Theme library dll (Telerik.Windows.Themes.Office_Black) and merged the needed .xaml files inside my App.xaml file. 

 

P.S. When I was running the code "as is" everething was  working properly (see attached images)

0
Accepted
Martin Ivanov
Telerik team
answered on 08 Nov 2017, 09:41 AM
Hello Dmitry,

Thank you for the provided information.

The annotations are not shown in NoXaml scenario because the descriptor Styles are not based on the default annotation styles. Basically, when you use custom style for any of the UI for WPF controls in a NoXaml scenario you will need to base it on the control's default style. Otherwise, the control won't be rendered. This is because the custom style completely overrides the default implicit style including the Template of the control. 

To resolve the issue you can add the BasedOn attribute to all descriptor styles targeting the annotations. For example:
<telerik:ChartAnnotationDescriptor.Style>
    <Style TargetType="telerik:CartesianGridLineAnnotation" BasedOn="{StaticResource CartesianGridLineAnnotationStyle}">
        <Setter Property="Value" Value="{Binding StartValue}" />
        <Setter Property="Axis" Value="{Binding VerticalAxis, RelativeSource={RelativeSource AncestorType=telerik:RadCartesianChart}}" />
        <Setter Property="Stroke" Value="Red" />
        <Setter Property="StrokeThickness" Value="2" />
    </Style>
</telerik:ChartAnnotationDescriptor.Style>
The default styles uses the following naming convention - [control name]Style. For example, CartesianGridLineAnnotationStyle, BarSeriesStyle, RadComboBoxStyle, etc.

I hope this helps. If you need any further assistance please let me know.

Regards,
Martin Ivanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Dmitry
Top achievements
Rank 1
answered on 08 Nov 2017, 11:59 AM
Thank you very much, Martin, for detailed explanation.
Tags
ChartView
Asked by
Dmitry
Top achievements
Rank 1
Answers by
Dmitry
Top achievements
Rank 1
Martin Ivanov
Telerik team
Share this question
or