Chartplotter in an Expander doesn't show legend etc

Oct 12, 2009 at 12:11 PM

 

 

<Expander Header="Calculated Angles" x:Name="CalculatedAnglesExpander">

                    <StackPanel Height="200">
                    <d3:ChartPlotter x:Name="measuredAgainstCalculatedAnglePlot" >
                        <d3:VerticalAxisTitle FontSize="12">Calculated Angle</d3:VerticalAxisTitle>
                        <d3:HorizontalAxisTitle FontSize="12">Measured Angle</d3:HorizontalAxisTitle>
                    </d3:ChartPlotter>
                        </StackPanel>

               </Expander>

I'm trying to use a ChartPlotter control within an expander but none of the text elements display.  The same chart works fine outside of the expander.

Any ideas what is going wrong here?

 

<Window .....
xmlns:d3="http://research.microsoft.com/DynamicDataDisplay/1.0"       
....
>
<Expander Header="Calculated Angles" x:Name="CalculatedAnglesExpander">
   <d3:ChartPlotter>
      <d3:VerticalAxisTitle FontSize="12">Calculated Angle</d3:VerticalAxisTitle>
      <d3:HorizontalAxisTitle FontSize="12">Measured Angle</d3:HorizontalAxisTitle>
   </d3:ChartPlotter>
</Expander>


 

 

 

Editor
Oct 14, 2009 at 3:32 PM

 

Hi!

I've tested how plotter works inside of Expander - and it works quite normal:

this is a picture of plotter inside of Expander:

 

I've used the following XAML markup:

 

<Window x:Class="PlotterInExpander.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d3="http://research.microsoft.com/DynamicDataDisplay/1.0"
    Title="Window1" Height="300" Width="300">
	<Expander Header="Expander">
		<d3:ChartPlotter>
			<d3:VerticalAxisTitle FontSize="12">Calculated Angle</d3:VerticalAxisTitle>
			<d3:HorizontalAxisTitle FontSize="12">Measured Angle</d3:HorizontalAxisTitle>
		</d3:ChartPlotter>
	</Expander>
</Window>

 

 

Maybe you simply need to expand the expander to view the plotter?

 

If you will still get wrong behavior of plotter in expander, post a message here.

Regards,

Mikhail.

Oct 15, 2009 at 10:58 AM

Thanks for replying.

I had thought that the problem was only related to the expander but it seems it is a combination of hosting the chartplotter in an expander and using the ExpressionDark theme from Codeplex wpf themes.  I presume the theme is changing the axis title text color from black to white but for some reason this only seems to occur when the chartplotter is hosted in an expander.  I have other instances of chartplotter in the same application that aren't in an expander that don't suffer from this problem.

I'd like to continue using the themes so will need to work out what is going wrong.  It's not obvious to me how you are drawing the text and so far I don't have any understanding of how the theme would cause the change I am seeing.  Any help would be most appreciated.

Regards,

Grant.

Oct 16, 2009 at 8:47 AM

Mikhail,

I have found that if I comment out the setting for the Foreground property (in the Expression Dark theme), text in the chartplotter (axis labels etc) is displayed correctly.

Do you know what is going wrong here?

    <Style TargetType="{x:Type Expander}">
<!--        <Setter Property="Foreground" Value="{DynamicResource TextBrush}" /> -->
        <Setter Property="Background" Value="Transparent" /> 
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="VerticalContentAlignment" Value="Stretch" />
        <Setter Property="BorderBrush" Value="Transparent" />
        <Setter Property="BorderThickness" Value="1" />

Regards,
Grant.
Editor
Oct 17, 2009 at 7:01 AM

Hi!

 

Since I cannot see how 'incorrectly' text is displayed, I can only make some presumptions:

1) Try to set plotter.Foreground to Black or

2) try to add into plotter's Resources the following style for TextBlocks:

 

<Style TargetType="{x:Type TextBlock}">
  <Setter Property="Foreground" Value="Black"/>
</Style>

Hope this will help, if not - I need to see what does it look like, when "text in the chartplotter (axis labels etc) is displayed correctly."

Best regards,

Mikhail.

 

Oct 18, 2009 at 10:07 AM

Mikhail,

Thanks for your help. Both your suggestions resolved the problem.

This is all probably just a misunderstanding on my part on the scope of wpf style setters.  I wasn't expecting the content of a control (in this case a chartplotter) to be changed by a style that was targeting the parent (expander).

 

<Window x:Class="WpfApplication7.AxisView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d3="http://research.microsoft.com/DynamicDataDisplay/1.0"
    Title="AxisView" Height="300" Width="300">
    <Window.Resources>
        <Style TargetType="{x:Type Expander}">
            <Setter Property="Foreground" Value="#FFFFFFFF" />
            <Setter Property="Background" Value="#FF595959" />
        </Style>
    </Window.Resources>

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <Expander Grid.Column="0" Grid.Row="0" Header="Chart in Expander" ExpandDirection="Down">
            <d3:ChartPlotter x:Name="ChartInExpander">               
                <d3:VerticalAxisTitle FontSize="12">Calculated Angle</d3:VerticalAxisTitle>
                <d3:HorizontalAxisTitle FontSize="12">Measured Angle</d3:HorizontalAxisTitle>
            </d3:ChartPlotter>            
        </Expander>
        <TextBlock Grid.Row="1">Chart in Grid Row</TextBlock>
        <d3:ChartPlotter Grid.Row="2">
            <d3:VerticalAxisTitle FontSize="12">Calculated Angle</d3:VerticalAxisTitle>
            <d3:HorizontalAxisTitle FontSize="12">Measured Angle</d3:HorizontalAxisTitle>
        </d3:ChartPlotter>
    </Grid>
</Window>
Regards,
Grant.
Editor
Oct 18, 2009 at 4:07 PM

Hi Grant,

I suppose this happens because Foreground is a property with Inherits in metadata, that's why when it is set in parent, all nested TextBlocks in ChartPlotter we were using for showing text strings got the same value.

Regards,

Mikhail.