djsmith Posted September 24, 2008 Report Share Posted September 24, 2008 When I set the SeriesAttributes Visibility property to Visibility.Hidden, the Legend doesn't reflect the series being hidden? Is there a way to do this? Quote Link to comment Share on other sites More sharing options...
JuanC Posted September 24, 2008 Report Share Posted September 24, 2008 That's an interesting issue. You can change the template for a legend box item, so we have a sample/prototype that shows checkboxes in the legend box to allow you to show/hide series. Obviously if unchecking a series would cause the legend box item to dissapear it would give you no way to turn it back on. We have also already assigned meaning to Visibility.Hidden/Visibility.Collapsed, Hidden will cause the series to still "contribute" to the pane or axis this series is attached to. (Note that in the current builds only pane functionality has been implemented but future builds will also incorporate axis functionality). Because of this we will be adding a property called ShowHiddenSeries in the LegendBox, when set to false you will get the behavior you want. Regards, JuanC Quote Link to comment Share on other sites More sharing options...
cvarro Posted September 24, 2008 Report Share Posted September 24, 2008 Can you post or email me the sample/prototype with the checkboxes in the legend box to allow showing / hiding of series? Thanks, -Chris Quote Link to comment Share on other sites More sharing options...
JuanC Posted September 25, 2008 Report Share Posted September 25, 2008 You will need these namespaces in your root node xmlns:cfxConverters="clr-namespace:ChartFX.WPF.Converters;assembly=ChartFX.WPF"xmlns:cfxControls="clr-namespace:ChartFX.WPF.Controls;assembly=ChartFX.WPF"This template in your Window/Page resources <DataTemplate x:Key="CheckableLegend"> <DataTemplate.Resources> <cfxConverters:VisibilityToBooleanConverter x:Key="visibilityToBool"/> </DataTemplate.Resources> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" SharedSizeGroup="FirstRow"/> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <CheckBox Background="{Binding Path=Fill}" IsChecked="{Binding Path=Visibility, Converter={StaticResource visibilityToBool}}" Margin="2,0" VerticalAlignment="Center"/> <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}" Foreground="{Binding Path=Foreground}" FontFamily="{Binding Path=FontFamily}" FontSize="{Binding Path=FontSize}" FontStyle="{Binding Path=FontStyle}" FontWeight="{Binding Path=FontWeight}"/> </Border> </Grid> <DataTemplate.Triggers> <DataTrigger Binding="{Binding Path=Dimmed}"> <DataTrigger.Value> <sys:Boolean>True</sys:Boolean> </DataTrigger.Value> <Setter Property="Opacity" Value="0.25" /> </DataTrigger> </DataTemplate.Triggers></DataTemplate>And this code in your Window/Page Loaded event chart1.LegendBox.ItemAttributes[chart1.Series].Template = (DataTemplate) FindResource("CheckableLegend"); Please note the following: - VisibilityToBooleanConverter will collapse when the boolean is false, future builds will support a property to change this behavior.- By using MarkerLegendControl you are allowing us to represent different galleries with different shapes, you could also "draw" your own shape and bind to properties such as Fill, Stroke, etc.- Wrapping the ContentControl inside a border fixes an issue trapping mouse events for highlight purposes. Regards, JuanC Quote Link to comment Share on other sites More sharing options...
djsmith Posted September 25, 2008 Author Report Share Posted September 25, 2008 Thanks Juan. I'm actually looking for something a little simpler than that even. Is it possible for me to set the chart1.LegendBox.ItemsAttributes through XAML? chart1.LegendBox.ItemAttributes[chart1.Series].Template = ( DataTemplate) FindResource("CheckableLegend");We're not using code-behind for our bindings or anything. Quote Link to comment Share on other sites More sharing options...
JuanC Posted September 26, 2008 Report Share Posted September 26, 2008 Unfortunately the ItemAttributes collection in the LegendBox class cannot be serialized in XAML in the current build. We will research if we can change this for future builds but we would have to do so in such a way that the current public API is not affected. 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.