in

Software FX Community

Discuss and find help for all Software FX products.

CheckLegend Template from Samples

Last post 06-01-2009 4:14 PM by JuanC. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 06-01-2009 12:35 PM

    CheckLegend Template from Samples

    Hi

     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">

    <DataTemplate.Resources>

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

    </DataTemplate.Resources>

    <Grid Name="grid">

    <Grid.ColumnDefinitions>

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

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

    <ColumnDefinition Width="*" />

    </Grid.ColumnDefinitions>

    <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}" />

    </Border>

    </Grid>

    <DataTemplate.Triggers>

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

    <DataTrigger.Value>

    <sys:Boolean>True</sys:Boolean>

    </DataTrigger.Value>

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

    </DataTrigger>

    </DataTemplate.Triggers>

    </DataTemplate>

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

    <Style.Setters>

    <Setter Property="Template">

    <Setter.Value>

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

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

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

    <ItemsPresenter />

    </ScrollViewer>

    </Expander>

    </ControlTemplate>

    </Setter.Value>

    </Setter>

    </Style.Setters>

    </Style>

     

    Our code that itterates though series to toggle visibility is:

    foreach (SeriesAttributes series in mChart.Series)

    {

    if (mAllSeriesOn)

    series.Visibility = Visibility.Visible;

    else

    series.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

     

    Paul

     

  • 06-01-2009 4:14 PM In reply to

    • JuanC
    • Top 10 Contributor
    • Joined on 03-02-2007

    Re: CheckLegend Template from Samples

    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" />

    Regards,

    JuanC

    Filed under:
Page 1 of 1 (2 items)
Copyright 2008 Software FX, Inc.