Jump to content
Software FX Community

Legend Box Formatting


Mick

Recommended Posts

If all labels are similar or you do not care about alignment you could change the Panel used by the legend as follows

<cfx:Chart.LegendBox>

  <cfx:LegendBox Visibility="Visible" DockPanel.Dock="Bottom">

  <cfx:LegendBox.ItemsPanel>

  <ItemsPanelTemplate>

  <WrapPanel/>

  </ItemsPanelTemplate>

  </cfx:LegendBox.ItemsPanel>

<cfx:LegendBox.ContainerStyle>

<Style TargetType="{x:Type ItemsControl}">

<Setter Property="Template">

<Setter.Value>

<ControlTemplate>

<ItemsPresenter/>

</ControlTemplate>

</Setter.Value>

</Setter>

</Style>

</cfx:LegendBox.ContainerStyle>

  </cfx:LegendBox>

</cfx:Chart.LegendBox>

Note that we are also changing the ContainerStyle, if you do not this ItemsControl will use a ScrollViewer around the panel that would defeat the WrapPanel purpose. If you do care about alignment and have knowledge about the number of items and size of the chart you could use UniformGrid instead.

<cfx:Chart.LegendBox>

  <cfx:LegendBox Visibility="Visible" DockPanel.Dock="Bottom">

  <cfx:LegendBox.ItemsPanel>

  <ItemsPanelTemplate>

<UniformGrid Rows="2"/>

  </ItemsPanelTemplate>

  </cfx:LegendBox.ItemsPanel>

  </cfx:LegendBox>

</cfx:Chart.LegendBox>

 

When using UniformGrid we do not need to set ContainerStyle.

Obviously both solutions are not optimal so starting in build 3688 (which should be available in a couple of days) you will be able to use a custom Chart FX panel called UniformOrientationGrid which will arrange items in a UniformGrid calculating the number of rows/columns automatically.

<cfx:Chart.LegendBox>

  <cfx:LegendBox Visibility="Visible" DockPanel.Dock="Bottom">

  <cfx:LegendBox.ItemsPanel>

  <ItemsPanelTemplate>

<cfxControls:UniformOrientationGrid/>

  </ItemsPanelTemplate>

  </cfx:LegendBox.ItemsPanel>

<cfx:LegendBox.ContainerStyle>

<Style TargetType="{x:Type ItemsControl}">

<Setter Property="Template">

<Setter.Value>

<ControlTemplate>

<ItemsPresenter/>

</ControlTemplate>

</Setter.Value>

</Setter>

</Style>

</cfx:LegendBox.ContainerStyle>

  </cfx:LegendBox>

</cfx:Chart.LegendBox>

JuanC

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...