Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF Toolkit Charts don't show if I change the ControlTemplate of a DataPoint in .NET 4
    text
    copied!<p>I am experiencing a very weird problem with the WPF Toolkit Charts in a .NET 4 environment. Basically, I just want to customize the ToolTip template for ColumnDataPoints. To accomplish that, I copied the default style for a ColumnDataPoint from the toolkit source code (generic.xaml) into my control resources and changed the TooltipService part like this:</p> <pre><code>&lt;UserControl.Resources&gt; &lt;Style TargetType="charts:ColumnDataPoint" x:Key="CustomDataPointStyle"&gt; &lt;Setter Property="Background" Value="Orange" /&gt; &lt;Setter Property="BorderBrush" Value="Black" /&gt; &lt;Setter Property="BorderThickness" Value="1" /&gt; &lt;Setter Property="IsTabStop" Value="False" /&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="charts:ColumnDataPoint"&gt; &lt;Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Opacity="0" x:Name="Root"&gt; &lt;VisualStateManager.VisualStateGroups&gt; &lt;VisualStateGroup x:Name="CommonStates"&gt; &lt;VisualStateGroup.Transitions&gt; &lt;VisualTransition GeneratedDuration="0:0:0.1" /&gt; &lt;/VisualStateGroup.Transitions&gt; &lt;VisualState x:Name="Normal" /&gt; &lt;VisualState x:Name="MouseOver"&gt; &lt;Storyboard&gt; &lt;DoubleAnimation Storyboard.TargetName="MouseOverHighlight" Storyboard.TargetProperty="Opacity" To="0.6" Duration="0" /&gt; &lt;/Storyboard&gt; &lt;/VisualState&gt; &lt;/VisualStateGroup&gt; &lt;VisualStateGroup x:Name="SelectionStates"&gt; &lt;VisualStateGroup.Transitions&gt; &lt;VisualTransition GeneratedDuration="0:0:0.1" /&gt; &lt;/VisualStateGroup.Transitions&gt; &lt;VisualState x:Name="Unselected" /&gt; &lt;VisualState x:Name="Selected"&gt; &lt;Storyboard&gt; &lt;DoubleAnimation Storyboard.TargetName="SelectionHighlight" Storyboard.TargetProperty="Opacity" To="0.6" Duration="0" /&gt; &lt;/Storyboard&gt; &lt;/VisualState&gt; &lt;/VisualStateGroup&gt; &lt;VisualStateGroup x:Name="RevealStates"&gt; &lt;VisualStateGroup.Transitions&gt; &lt;VisualTransition GeneratedDuration="0:0:0.5" /&gt; &lt;/VisualStateGroup.Transitions&gt; &lt;VisualState x:Name="Shown"&gt; &lt;Storyboard&gt; &lt;DoubleAnimation Storyboard.TargetName="Root" Storyboard.TargetProperty="Opacity" To="1" Duration="0" /&gt; &lt;/Storyboard&gt; &lt;/VisualState&gt; &lt;VisualState x:Name="Hidden"&gt; &lt;Storyboard&gt; &lt;DoubleAnimation Storyboard.TargetName="Root" Storyboard.TargetProperty="Opacity" To="0" Duration="0" /&gt; &lt;/Storyboard&gt; &lt;/VisualState&gt; &lt;/VisualStateGroup&gt; &lt;/VisualStateManager.VisualStateGroups&gt; &lt;Grid Background="{TemplateBinding Background}"&gt; &lt;Rectangle&gt; &lt;Rectangle.Fill&gt; &lt;LinearGradientBrush&gt; &lt;GradientStop Color="#77ffffff" Offset="0" /&gt; &lt;GradientStop Color="#00ffffff" Offset="1" /&gt; &lt;/LinearGradientBrush&gt; &lt;/Rectangle.Fill&gt; &lt;/Rectangle&gt; &lt;Border BorderBrush="#ccffffff" BorderThickness="1"&gt; &lt;Border BorderBrush="#77ffffff" BorderThickness="1" /&gt; &lt;/Border&gt; &lt;Rectangle x:Name="SelectionHighlight" Fill="Red" Opacity="0" /&gt; &lt;Rectangle x:Name="MouseOverHighlight" Fill="White" Opacity="0" /&gt; &lt;/Grid&gt; &lt;ToolTipService.ToolTip&gt; &lt;StackPanel&gt; &lt;ContentControl Content="Custom ToolTip" FontWeight="Bold"/&gt; &lt;ContentControl Content="{TemplateBinding FormattedDependentValue}"/&gt; &lt;/StackPanel&gt; &lt;/ToolTipService.ToolTip&gt; &lt;/Border&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; </code></pre> <p></p> <p>Now, the problem is that as soon as I apply my CustomDataPointStyle (even if I don't change anything!), the ColumnSeries doesn't show at all in my chart.</p> <pre><code>&lt;Grid x:Name="ChartGrid" DataContext="{Binding}"&gt; &lt;charts:Chart x:Name="Chart1" Margin="5,0,0,0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Title="{Binding Path=Title}"&gt; &lt;charts:Chart.Axes&gt; &lt;charts:CategoryAxis Orientation="X" Title="{Binding Path=XAxisTitle}" Location="Bottom" /&gt; &lt;charts:CategoryAxis Orientation="Y" Title="{Binding Path=YAxisTitle}" Location="Right" ShowGridLines="True" /&gt; &lt;/charts:Chart.Axes&gt; &lt;charts:ColumnSeries x:Name="ColumnSeries" Title="{Binding Path=SeriesTitle}" ItemsSource="{Binding Path=Data}" DataPointStyle="{StaticResource CustomDataPointStyle}" DependentValueBinding="{Binding Path=Value}" IndependentValueBinding="{Binding Path=Key}"&gt; &lt;/charts:ColumnSeries&gt; &lt;/charts:Chart&gt; </code></pre> <p></p> <p>results in this:</p> <p><img src="https://i.stack.imgur.com/u2VFq.png" alt="enter image description here"></p> <p>I guess that I am missing a VisualState or something that actually renders the chart but how can that be, given that I copied(!) the original style? The Toolkit is made for .NET 3.5 and I have to use .NET 4 in my application - could that be the reason?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload