Jump to content
Software FX Community

CheckLegend Template from Samples


Recommended Posts


 We're using the above in conjunction with the collapsable legendbox style and were trying to add functionality to allow the user to select / de-select all.  While using a simple boolean to toggle all series on or off works, the legend box seems to get out of sync with the dependency property value, despite its binding. 

The styles are as follows:

<DataTemplate x:Key="CheckLegend">


<local:VisibilityToBooleanConverter x:Key="VisibilityToBool"/>


<Grid Name="grid">


<ColumnDefinition Width="*" SharedSizeGroup="FirstRow" />

<ColumnDefinition Width="*" SharedSizeGroup="FirstRow" />

<ColumnDefinition Width="*" />


<CheckBox VerticalAlignment="Center" Background="{Binding Path=Fill}" IsChecked="{Binding Path=Visibility, Converter={StaticResource VisibilityToBool}}" Grid.Column="0" Foreground="White" />

<cfxControls:MarkerLegendControl Content="{Binding Path=Self}" Grid.Column="1" />

<Border Background="Transparent" Grid.Column="2" VerticalAlignment="Center">

<ContentControl IsHitTestVisible="false" Content="{Binding Path=Content}" ContentTemplate="{Binding Path=ContentTemplate}" />




<DataTrigger Binding="{Binding Path=Dimmed}">




<Setter Property="Opacity" Value="0.25" TargetName="grid" />




<Style TargetType="{x:Type ItemsControl}" x:Key="LegendBoxStyle">


<Setter Property="Template">


<ControlTemplate TargetType="{x:Type ItemsControl}">

<Expander Header="Legend Box" Foreground="White">

<ScrollViewer Margin="0,5,0,0">

<ItemsPresenter />









Our code that itterates though series to toggle visibility is:

foreach (SeriesAttributes series in mChart.Series)


if (mAllSeriesOn)

series.Visibility =


elseseries.Visibility = Visibility.Hidden;




I have noticed that while the legend box is collapsed on first expand the checkboxes have the right value, but after this syncronisation with the underlying property is lost even if you collapse the legend again.

 Any thoughts on this?


Many thanks




Link to comment
Share on other sites

The key here is that when you assign a DataTemplate to be used in the legend box for a series, you are actually binding against a CLR object that hold series information (as well as some global info), this is the same object that exposes a Dimmed property even though Series does not have that property but is NOT the series itself.

We will fix this issue in future builds but as a workaround you can tweak your template to make sure you are binding to the Series.Visibility property, e.g.

<CheckBox VerticalAlignment="Center" Background="{Binding Path=Fill}" IsChecked="{Binding Path=Series.Visibility, Converter={StaticResource VisibilityToBool}}" Grid.Column="0" Foreground="White" />



Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...