I have a XamDataChart in a ContentPane and a Legend in another ContentPane. When the chart is visible (and on startup) the LegendItems show, when the chart is not visible they do not show. I have a LegendItemTemplate to override the Series.Visibility binding but I am unable to make the LegendItems visible when the chart is not.
I used Snoop to identify that while the Visibility property on the ContentControl of each LegendItem is set to Visible the IsVisible readonly property is set to false. The Legend is still visible but the LegendItems are not.
This is a screenshot of Snoop on the ContentControl that hides the LegendItem. All of the "(ContentControl) 9" objects represent a LegendItem.
A bigger issue may be that the LegendItem bindings are being wiped out (all of the yellow rows on the right indicate a changed property of the LegendItem's ContentControl when the chart is no longer visible).
Hi firebourne,
Sorry for the delayed response.
I was looking into this and I found that when the application initially starts up, the Legend has items from each chart, even ones that are not currently visible but once the user clicks on one of the tabbed content panes, it removes the legend items from non visible charts. I believe this is because the ContentPane that was just hidden is no longer part of the visual tree so the items are removed from the Legend as a result.
With regards to having a single legend item for multiple charts, the legend item is added based on the series in the chart, not the underlying data. And since charts can't share series objects, each chart needs to have it's own axis and series, there's going to be an entry in the legend for each series.
I've logged these both as new product ideas for the Legend and sent them directly to our product management team. Our product team chooses new product ideas for development based on popular feedback from our customer base. Infragistics continues to monitor application development for all of our products, so as trends appear in requested features, we can plan accordingly.
We value your input, and our philosophy is to enhance our toolset based on customer feedback. If your feature is chosen for development, you will be notified at that time. Your reference number for these product ideas are PI13020114 and PI13020115. PI13020114 is for showing legend items even when the chart is hidden and PI13020115 is for using a single legend with multiple charts without duplicating legend items.
If you would like to follow up on your product idea at a later point, you may contact Developer Support management via email. Please include the reference number of your product idea in the subject and body of your email message. You can reach Developer Support management through the following email address: dsmanager@infragistics.com
Hi Rob,
I understand. It's not that I really wanted a single legend for multiple charts (I understand the series to legend item relationship) but rather I wanted to simulate that effect by keeping the legend items visible from one of the charts regardless of that chart being visible or not. It seems odd that there is no way to keep legend items visible when the legend is still visible. I would have thought that setting the style for the legend item would have accomplished this (or possibly a control template higher in the visual tree).
Since there is no built-in way to accomplish this visibility task, what is the quickest way to reproduce the style of a legend item in another control such as a listview or something? I will need to retrieve the color for the legend item as well (to reproduce the marker).
I would just put the legends back in the charts but I want to be able to make the charts very small if the user lays things out that way and would need to drop the legends at that point.
I understand where you're coming from about keeping the charts very small so it's not really possible to have a legend visible inside each one. However, since legend items are tied to a chart series, if that series is not in the visual tree it will remove the associated legend item. The charts that are in different tabs are not in the visual tree so they don't get a legend item. This is just how the legend was designed. This is why I logged the product ideas in my previous post.
You can definitely create your own legend however. Each series has the properties you'll need to get the color and the template for the marker that you normally see in the legend. The ActualBrush and LegendItemBadgeTemplate properties will give you the series color and the template used in the legend for the icon next to the series name. You can then feed the ListView a collection of all the series available in each chart, even the ones not visible, and use these properties to mimic the appearance of the legend.
Let me know if you have any further questions on this issue.
I wanted to thank you. Reproducing the legend in the ListView was exceedingly simple. Since I show the same items in all charts I now have a single legend for all charts. This is a great workaround and wouldn't take any time to provide as a new Legend control if Infragistics decided to do that at some point. That is an obvious over-simplification but it works very well in this case and I have the desired control over my series items and the visibility of the pseudo-legend items.
Thank you very much!