MMCCPaulEden Posted June 1, 2009 Report Share Posted June 1, 2009 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; 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 Paul Quote Link to comment Share on other sites More sharing options...
JuanC Posted June 1, 2009 Report Share Posted June 1, 2009 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.