Skip to main content

Microsoft Silverlight

How to find control in chart template in code.RSS Feed

(0)

mahendra.gurav
mahendra...

Member

Member

136 points

158 Posts

How to find control in chart template in code.

Hi,

  I hve template in chart. I need to find Grid row in code behind which is present in template.

My code is as below

 

<chart:Chart.Template>
                    <ControlTemplate TargetType="chart:Chart">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition x:Name="rowChartArea"/>

                            </Grid.RowDefinitions>

                            <Grid x:Name="ChartArea" Style="{TemplateBinding ChartAreaStyle}" Grid.Row="0">
                                <Grid x:Name="PlotArea" Style="{TemplateBinding PlotAreaStyle}">

                                    <Grid x:Name="GridLinesContainer" Background="White" />

                                    <Grid x:Name="SeriesContainer" />

                                </Grid>
                            </Grid>

                        </Grid>
                    </ControlTemplate>
                </chart:Chart.Template>

I want to set height of rowChartArea from code

so how can i do that.

 

Thanks,

Mahendra

Amanda Wang - MSFT
Amanda W...

All-Star

All-Star

17241 points

1,466 Posts

Re: How to find control in chart template in code.

 Hi Mahendra,

You  can get the Gird object that is in the Chart's tempate by using silverlight's  VisualTreeHelper that is used to traverse the object relationships (along child object or parent object axes) in the Silverlight visual tree.

The more about the VisualTreeHelper, you can try to check this msdn link: http://msdn.microsoft.com/en-us/library/system.windows.media.visualtreehelper(VS.95).aspx

Amanda Wang
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.

mahendra.gurav
mahendra...

Member

Member

136 points

158 Posts

Re: How to find control in chart template in code.

Hi,

Thanks for reply...Can u plz give sample code for the same?

 

Regards,

Mahendra..

 

 

raj.jadhav
raj.jadhav

Member

Member

54 points

107 Posts

Re: How to find control in chart template in code.

HI,

 

   I need same functionality. I have template in chart control as below

 

<chart:Chart.Template>

<ControlTemplate TargetType="chart:Chart">

<Grid Margin="0">

<Grid.RowDefinitions>

<!--<RowDefinition Height="25"/>-->

<RowDefinition x:Name="rowChart" Height="200"/>

</Grid.RowDefinitions>

<Grid x:Name="ChartArea" Style="{TemplateBinding ChartAreaStyle}" Grid.Row="0">

<Grid x:Name="PlotArea" Style="{TemplateBinding PlotAreaStyle}">

<Border BorderBrush="Gray" BorderThickness="1">

<Grid x:Name="GridLinesContainer" Background="White" />

</Border>

<Grid x:Name="SeriesContainer" />

</Grid>

</Grid>

</Grid>

</ControlTemplate>

</chart:Chart.Template>

 

Here i set row height as 200 for grid row. I need to set ot from code.So how can i find row in  code behind. Also want to find controls in grid.

So please give sample code for that.

 

Thanks in advance,

Rajesh

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities