Using an Expander with a GridSplitter and NChartControl WPF


https://www.nevron.com/Forum/Topic9643.aspx
Print Topic | Close Window

By Fabio Olcese - 8 Years Ago
The expander won't work properly. When I try to collapse the expander it will just leave a blank space and as soon as I move the GridSplitter it will properly collapse. When I try to expand it it won't do anything making it necessary to move the GridSplitter to the left so that the NChartControl appear.

I understand the the Expander and GridSplitter don't work well together so I am using the ExpanderGrid taken out from this page: http://www.cenito.se/2014/11/gridsplitter-expander-dont-work-together/ which made it work well with other Charting Components. 

It would seem that normally that the OnChildDesiredSizeChanged of the ExpanderGrid won't trigger when clicking the expander button as it would normally do.

The xaml code its something like this:

<v:ExpanderGrid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
    
    <v:ExpanderGrid.ColumnDefinitions>
      <ColumnDefinition Width="2*"/>
      <ColumnDefinition Width="5"/>
      <ColumnDefinition Width="2*"/>
    </fv:ExpanderGrid.ColumnDefinitions>
    
    <DockPanel Grid.Column="0">
      <UserControl/>
      <UserControl/>
    </DockPanel>
    
    <GridSplitter Grid.Column="1" Width="5" HorizontalAlignment="Stretch"/>

    <Expander Grid.Column="2" ExpandDirection="Left" IsExpanded="{Binding Property}">
      <UserControl with NChartControl/>
    </Expander>

   </v:ExpanderGrid>

Thanks in advance.
By Nevron Support - 8 Years Ago
Hi Fabio,

Can you send us a project replicating this problem? Also what is the version of the control you're testing with?
By Fabio Olcese - 8 Years Ago
Thanks for the response. The small project reproducing the problem. has size of 7.9 MB and I can't actually attach it here. How can i send it you?
By Nevron Support - 8 Years Ago
Hi Fabio,

Just send it to support@nevron.com . Thank you.
By Nevron Support - 8 Years Ago
Hi Fabio,
 
The problem is that the chart control does not have preferred width/height. To solve the problem simply assign some width / height to the chart:
 
Plot.Width = 400;
Plot.Height = 300;  

Let us know if you meet any problems or have any questions.
By Fabio Olcese - 8 Years Ago
Yes that sets up an initial width and height for the plot, but what if I want it to stretch to the current width of the column? For example if I move the gridsplitter to the left you can clearly see it is an static width.
By Fabio Olcese - 8 Years Ago
I thought that I replied earlier but apparently I didn't. Yes setting up the width and height fixed the issue of the expander not being expanded when you start the project, but what if I want the chart to stretch to the current width of the column. For example if you move the GridSplitter to the left you will see that the chart won't stretch. How can I do this?

Thanks in advance.
By Nevron Support - 8 Years Ago
Hi Fabio,

We think the problem is that the control did not have a measured size -
overriding the MeasureOverride seems to fix this problem:
protected override System.Windows.Size MeasureOverride(System.Windows.Size constraint)  
{
    return new System.Windows.Size(Math.Min(constraint.Width, 400), Math.Min(constraint.Height, 300));   
}
this fix will be available in the upcoming release.