Jump to content
Software FX Community

Controlling the size


Recommended Posts


I want to display pie charts in a ListBox and would like that they size such that they fill the available space of the listbox. I cant figure out how to control the size of the Chart in this regard?

 Any ideas?



Window x:Class="WpfApplication14.Window1"





Title="Window1" Height="400" Width="600" xmlns:ChartFX="http://schemas.softwarefx.com/chartfx/wpf/80">


<ListBox ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Disabled">



<StackPanel Orientation="Horizontal" IsItemsHost="True" />





<ChartFX:Chart Gallery="Pie">


<ControlTemplate TargetType="{x:Type ChartFX:Chart}">

<DockPanel ChartFX:Chart.PanelName="Plot" />



<ChartFX:SeriesAttributes />



<clr:String>Item 1</clr:String>

<clr:String>Item 2</clr:String>

<clr:String>Item 3</clr:String>



Link to comment
Share on other sites

The problem with StackPanel is that it does not inform its children on the available size in the "stacked" direction, if you create a class that derives from control and override the MeasureOverride/ArrangeOverride functions you will notice that the controls will receive the available width but will receive double.PositiveInfinity as the available height.

If you wanted the charts to have a fixed height you could do so (e.g. Height="200") but obviously depending on the number of charts (items in the listbox) would result on unused space or scrollbars.

For this scenario I would recommend using a UniformGrid in the ItemsPanelTemplate instead of a StackPanel. You might want to set Columns="1" to force the grid to create as many rows as elements in the listbox.



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.

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...