Hi
We are looking at using Telerik charts to replace an older WinForms charting widget, and we need to maintain backwards compatibility in order to maintain the correct look and feel. Our previous charting widgets heavily supported 3D charting, but Telerik's 3D charts are not particularly similar in visual style to the ones we are looking to replace. I have been looking at ChartArea, and have noticed that there is a Template3D that is used to dictate how the 3D charts are set up visually, and this would be perfect to use for what we want to do. In attempting to create a custom style in order to specify our own Template3D, I have been running into a few problems. Currently, I have a ChartArea style that specifies our custom Template3D, which I have pulled from looking at the default Template3D normally used:
However, when I try to assign this style to the ChartArea of any 3D chart, I get a null reference exception in RadChart. The call stack gives the last few calls as:
Telerik.Windows.Controls.Charting.dll!Telerik.Windows.Controls.Charting.Series3D.ChartArea.get()
Telerik.Windows.Controls.Charting.dll!Telerik.Windows.Controls.Charting.Series3D.LabelsControl.get()
Telerik.Windows.Controls.Charting.dll!Telerik.Windows.Controls.Charting.Series3D.RemoveLabelLayer()
So my question is how do I properly set Template3D (if it even possible)?
We are looking at using Telerik charts to replace an older WinForms charting widget, and we need to maintain backwards compatibility in order to maintain the correct look and feel. Our previous charting widgets heavily supported 3D charting, but Telerik's 3D charts are not particularly similar in visual style to the ones we are looking to replace. I have been looking at ChartArea, and have noticed that there is a Template3D that is used to dictate how the 3D charts are set up visually, and this would be perfect to use for what we want to do. In attempting to create a custom style in order to specify our own Template3D, I have been running into a few problems. Currently, I have a ChartArea style that specifies our custom Template3D, which I have pulled from looking at the default Template3D normally used:
<Style x:Key="defaultAreaStyle" TargetType="c:ChartArea"> <Setter Property="Template3D"> <Setter.Value> <ControlTemplate TargetType="c:ChartArea"> <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> <ItemsPresenter/> <Grid x:Name="PART_Container"/> <c:ViewportPanel x:Name="PART_CameraExtensionCanvas"> <Viewport3D x:Name="PART_ViewPort3D"> <Viewport3D.Camera> <PerspectiveCamera LookDirection="0.2,-0.23,-1" Position="-40,37.5,195"/> </Viewport3D.Camera> <ModelVisual3D> <ModelVisual3D.Content> <Model3DGroup> <AmbientLight Color="#FF606060"/> <DirectionalLight Color="#FF989898" Direction="-0.5,-0.4,-1"/> </Model3DGroup> </ModelVisual3D.Content> </ModelVisual3D> <ContainerUIElement3D> <ContainerUIElement3D.Transform> <Transform3DGroup> <TranslateTransform3D OffsetX="-50" OffsetY="-37.5"/> </Transform3DGroup> </ContainerUIElement3D.Transform> <c:PlaneZX AdornerLayer="{x:Null}" Height="2" SecondaryTicksSource="{Binding AxisX.TickPoints, RelativeSource={RelativeSource TemplatedParent}}" SecondaryAxis3DPoints="0,0,10.1 100,0,10.1"> <c:PlaneZX.PositionTransform> <TranslateTransform3D OffsetZ="0" OffsetX="0" OffsetY="-2"/> </c:PlaneZX.PositionTransform> </c:PlaneZX> <c:PlaneXY AdornerLayer="{x:Null}" Depth="2" PrimaryTicksSource="{Binding AxisX.TickPoints, RelativeSource={RelativeSource TemplatedParent}}" SecondaryTicksSource="{Binding AxisY.TickPoints, RelativeSource={RelativeSource TemplatedParent}}"> <c:PlaneXY.PositionTransform> <TranslateTransform3D OffsetZ="-2" OffsetX="0" OffsetY="0"/> </c:PlaneXY.PositionTransform> </c:PlaneXY> <c:PlaneYZ AdornerLayer="{x:Null}" PrimaryTicksSource="{Binding AxisY.TickPoints, RelativeSource={RelativeSource TemplatedParent}}" PrimaryAxis3DPoints="0,0,10.1 0,75,10.1" Width="2"> <c:PlaneYZ.PositionTransform> <TranslateTransform3D OffsetZ="0" OffsetX="-2" OffsetY="0"/> </c:PlaneYZ.PositionTransform> </c:PlaneYZ> <c:ItemsPresenter3D/> </ContainerUIElement3D> </Viewport3D> <c:LabelsControl x:Name="PART_LabelsControl" ClipToBounds="True"> <c:LabelsControl.ItemsPanel> <ItemsPanelTemplate/> </c:LabelsControl.ItemsPanel> <c:LabelsControl.ItemTemplate> <DataTemplate> <c:LabelLayer> <c:LabelLayer.ItemsPanel> <ItemsPanelTemplate> <c:LabelLayerItemsPanel IsItemsHost="True"/> </ItemsPanelTemplate> </c:LabelLayer.ItemsPanel> <c:LabelLayer.ItemTemplate> <DataTemplate> <Border BorderBrush="#FF5C5C5C" BorderThickness="1" CornerRadius="3" LayoutTransform="{Binding Transform}"> <Border.Background> <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> <GradientStop Color="#FFCCCCCC" Offset="1"/> <GradientStop Color="White"/> </LinearGradientBrush> </Border.Background> <TextBlock Foreground="Black" FontWeight="Bold" HorizontalAlignment="Center" Margin="4,0"> <TextBlock.Text> <Binding> <Binding.Converter> <c:LabelFormatConverter/> </Binding.Converter> </Binding> </TextBlock.Text> </TextBlock> </Border> </DataTemplate> </c:LabelLayer.ItemTemplate> </c:LabelLayer> </DataTemplate> </c:LabelsControl.ItemTemplate> </c:LabelsControl> </c:ViewportPanel> <c:NoDataControl x:Name="PART_NoData" Style="{TemplateBinding NoDataControlStyle}"/> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style>However, when I try to assign this style to the ChartArea of any 3D chart, I get a null reference exception in RadChart. The call stack gives the last few calls as:
Telerik.Windows.Controls.Charting.dll!Telerik.Windows.Controls.Charting.Series3D.ChartArea.get()
Telerik.Windows.Controls.Charting.dll!Telerik.Windows.Controls.Charting.Series3D.LabelsControl.get()
Telerik.Windows.Controls.Charting.dll!Telerik.Windows.Controls.Charting.Series3D.RemoveLabelLayer()
So my question is how do I properly set Template3D (if it even possible)?