Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
535
Is it possible to create wrapping horizontal legend?
posted

Hi, I have been trying to create xamDataChart with wrapping horizontal legend where legend items show up on multiple lines instead of default behaviour (one line and horizontal scrollbar). I'm using Infragistics version 13.1.

I found similar questions asked here before, and they suggested replacing StackPanel which contains legend items with WrapPanel on datachart's loaded event like this:

private void DataChart_Loaded(object sender, RoutedEventArgs e)
{
   ContentPresenter cp = Utilities.GetDescendantFromName(_legend, "ContentPresenter") as ContentPresenter;
   WrapPanel wp = new WrapPanel() { Orientation = System.Windows.Controls.Orientation.Horizontal };
   StackPanel sp = cp.Content as StackPanel;

   int count = sp.Children.Count;
   for (int i = 0; i < count; i++)
   {
      ContentControl cc = sp.Children[0] as ContentControl;
      sp.Children.Remove(sp.Children[0] as ContentControl);
      wp.Children.Add(cc);
   }

   cp.Content = wp;
}

This was marked as verified answer here, but I get InvalidOperationException from it: "Specified element is already the logical child of another element. Disconnect it first." Is there something I'm missing here, or has this solution deprecated somewhere before version 13.1?

I also tried a different approach to my problem. Here I define own legends for each serie like this:

<ig:XamDataChart>

...

<ig:ColumnSeries Legend="{Binding ElementName=TitleLegend1}" ...

<ig:ColumnSeries Legend="{Binding ElementName=TitleLegend2}" ...

<ig:ColumnSeries Legend="{Binding ElementName=TitleLegend3}" ...

...

</ig:XamDataChart>

<ig:XamDock ig:XamDock.Edge="OutsideBottom" ig:XamDock.HorizontalDockAlignment="Center">
   <WrapPanel>
      <ig:Legend x:Name="TitleLegend1" />

      <ig:Legend x:Name="TitleLegend2" />

      <ig:Legend x:Name="TitleLegend3" />

      ...

   </WrapPanel>

</ig:XamDock>

This works fine and I like that I can style and construct the whole legend area and individual legends by myself. Legend items wrap nicely to multiple rows when needed. Problem is that my chart can also have stacked series:

<ig:StackedColumnSeries Legend="{Binding ElementName=TitleLegend4}" ...
   <ig:StackedColumnSeries.Series>
      <ig:StackedFragmentSeries />
      <ig:StackedFragmentSeries />
      <ig:StackedFragmentSeries />

     ...

   </ig:StackedColumnSeries.Series>

</ig:StackedColumnSeries>

So this stacked serie can have only one legend (TitleLegend4) where it show all fragment series using default legend template (StackPanel and no wrapping). Is it possible to define own legend for each StackedFragmentSeries? It would make this solution to work for my needs.

By the way, does this question form support code formatting like for example StackOverflow? It would make writing and reading questions including code snippets much easier.

Best regards, Henri

Parents Reply
  • 35319
    posted in reply to Tg

    Hello,

     

    Thank you for your feedback. This exception occurs because of the used custom approach.

     

    After working on this and doing some research, this functionality has been determined to be a new product idea. You can suggest new product ideas for future versions (or vote for existing ones) at <http://ideas.infragistics.com>.

     

    There are many benefits to submitting an product idea:

     

    -          Direct communication with our product management team regarding your product idea.

    -          Notifications whenever new information regarding your idea becomes available.

    -          Ability to vote on your favorite product ideas to let us know which ones are the most important to you.  You will have ten votes for this and can change which ideas you are voting for at any time.

    -          Allow you to shape the future of our products by requesting new controls and products altogether.

    -          You and other developers can discuss existing product ideas with members of our Product Management team.

     

    Steps to create your idea:

                   

    1. Log into the Infragistics Product Idea site at http://ideas.infragistics.com (creating a new login if needed).
    2. Navigate to the product / platform channel of your choice (e.g. WPF, Windows Forms, ASP.NET, HTML5 / Ignite UI, iOS / NucliOS, etc.)
    3. Add your product idea and be sure to be specific and provide as much detail as possible. Explain the context in which a feature would be used, why it is needed, why it can’t be accomplished today, and who would benefit from it. You can even add screenshots to build a stronger case. Remember that for your suggestion to be successful, you need other members of the community to vote for it. Be convincing!

     

     

    The Product Idea site puts you in the driver’s seat and allows you to track the progress of your ideas at any time, see how many votes it got, read comments from other developers in the community, and see if someone from the product team has additional questions for you.

     

    Thank you for contacting Infragistics.

Children