I am trying write a template to Legend control. I have version 10.3, .net 4, xamDataChart, with a few line series.
My Legend is Horizontal and I want this to wrap when i have many items(series). Something thing like tab control showing multiple lines. Is this possible? I have to have my Legend at the Top.
I have custom Legend template and Legendtemplateitem, but it's not working. I just comented the ScrowViewer and replace this for a WrapPanel.
Any Help is welcome.
<ControlTemplate x:Key="xamDataChartLegendTemplate" TargetType ="Charts:Legend">
<Grid>
<Border BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" CornerRadius="4" Background="{TemplateBinding Background}">
<Grid Margin="{TemplateBinding Padding }">
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<ContentPresenter Grid.Row="0" Content="{TemplateBinding Content}" />
<!--<ScrollViewer Grid.Row="1" HorizontalScrollBarVisibility="auto" VerticalScrollBarVisibility="auto" BorderThickness="0" Background="Transparent">-->
<WrapPanel Orientation="Horizontal" Grid.Row="1">
<ContentPresenter Grid.Row="1" x:Name="ContentPresenter" />
</WrapPanel>
<!--</ScrollViewer>-->
</Grid >
</Border>
<Border IsHitTestVisible="False" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="Transparent" CornerRadius="4" Background="{StaticResource GenericOverlay}" />
</Grid>
</ControlTemplate>
<
DataTemplate x:Key="xamDataChartCustomLegendItemTemplate">
.Visibility}">
.LegendItemBadgeTemplate}" />
}"/>
We would also benefit from the ability to change the Legend Panel. Please consider this change for future releases.
Meanwhile, your example shows a WrapPanel created when the chart is loaded. This works well if you have a static number of series, however if you add an additional series in codebehind, the legend will not update. It seems that the Chart itself updates the legend. Can you tell me how to get this to work with the wrappanel so that it can dynamically update when adding and removing series?
Hello,
After some research Ability yo set the Legend's Items' panel has been determine as a new Product Idea. I have sent your Product Idea 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 ideas, we can plan accordingly.
We value your input, and our philosophy is to enhance our toolset based on customer feedback. If your idea is chosen for development, you will be notified at that time. Your reference number for this Product Idea is PI12060038
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 Stefan,
I know your sample code works. I have two chart user controls in my project and for the first chart user control using what you have in your sample works with no issue. The other chart I can toggle back and forth between the two but if I change tabs ( I have multiple tabs with multiple charts on them) I get the ' child already belongs to parent' exception. The obvious answer is the issue is somewhere in my code. I've tried everything I can think of and am unable to find it. So what I really meant in my above post was is it possible to set up a template for the items in your legends content presenter in xaml or will the content presenter.context property always default to a stackpanel. The reason I would like to do it this way is it would avoid moving child items between a stackpanel and wrappanel. I believe this would resolve my issue and allow for multiple layouts of legend items in a legend using the content template selector.
If you could send me an isolated sample project where your issue is reproduced, I would be able to investigate it further for you.
Looking forward for your reply.
Hey Stefan,
I'm trying to give the user an option to have the Legend on the graph display it's items vertically or dock the legend below the chart with it's items displayed horizontally. Unfortunately when I move the legend items children between a wrappanel and a stackpanel just as in your example I get a nasty 'Child already belongs to a parent' exception.
Is it not at all possible to change the content presenters layout like the original poster talked about? It seems that the default items layout in the legends content presenter is a Stackpanel. What I would like to do is have two templates for displaying these legend items in a Wrappanel and in a Stackpanel. If I can just figure out how to set the legend items display in Xaml I'm sure I can figure out the rest.
I though something like this might work but I think this is just template for each item in the legend and not a template around the items in a legend.
<ContentPresenter x:Name="ContentPresenter"> <!--<ContentPresenter.ContentTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <ContentPresenter Content="{Binding}" ContentTemplate="{Binding Series.LegendItemTemplate}" VerticalAlignment="Center"/> </StackPanel> </DataTemplate> </ContentPresenter.ContentTemplate>--> </ContentPresenter>
I would really appreciate any help I can get.