/
CustomAxisInfoTemplateSelector.cs
54 lines (47 loc) · 2.12 KB
/
CustomAxisInfoTemplateSelector.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// *************************************************************************************
// SCICHART® Copyright SciChart Ltd. 2011-2022. All rights reserved.
//
// Web: http://www.scichart.com
// Support: support@scichart.com
// Sales: sales@scichart.com
//
// CustomAxisInfoTemplateSelector.cs is part of the SCICHART® Examples. Permission is hereby granted
// to modify, create derivative works, distribute and publish any part of this source
// code whether for commercial, private or personal use.
//
// The SCICHART® examples are distributed in the hope that they will be useful, but
// without any warranty. It is provided "AS IS" without warranty of any kind, either
// expressed or implied.
// *************************************************************************************
using System.Windows;
using SciChart.Charting.Common.Helpers;
using SciChart.Charting.Visuals.RenderableSeries;
namespace SciChart.Examples.Examples.SeeFeaturedApplication.Oscilloscope
{
public class CustomAxisInfoTemplateSelector : AxisInfoTemplateSelector
{
public static readonly DependencyProperty EmptyDataTemplateProperty = DependencyProperty.Register("EmptyDataTemplate", typeof(DataTemplate), typeof(CustomAxisInfoTemplateSelector), new PropertyMetadata(OnDefautlTemplateDependencyPropertyChanged));
public DataTemplate EmptyDataTemplate
{
get { return (DataTemplate) GetValue(EmptyDataTemplateProperty); }
set { SetValue(EmptyDataTemplateProperty, value); }
}
public override DataTemplate SelectTemplate(object item, DependencyObject container)
{
var axisInfo = item as AxisInfo;
var dataTemplate = base.SelectTemplate(item, container);
if (axisInfo != null)
{
if (axisInfo.AxisId == "DefaultAxisId")
{
dataTemplate = axisInfo.IsXAxis ? XAxisDataTemplate : YAxisDataTemplate;
}
else
{
dataTemplate = EmptyDataTemplate;
}
}
return dataTemplate;
}
}
}