How to get the control in resource when I show the chart using mvvm binding?

2 posts, 1 answers
  1. PEIYANG
    PEIYANG avatar
    65 posts
    Member since:
    Jul 2012

    Posted 26 Sep 2012 Link to this post

    in this sample http://localhost:6519/Default.aspx#Chart/SimpleFiltering,I want to get the control called checkbox1,but I cant get it with this.checkbox1,How to get the checkbox1??
      <UserControl.Resources>  
            <example:ExampleViewModel x:Key="ViewModel" />
            <Style x:Key="CustomLegendItemStyle" TargetType="charting:ChartLegendItem">  
                <Setter Property="Foreground" Value="Black" />
                <Setter Property="Template" >
                    <Setter.Value>
                        <ControlTemplate TargetType="charting:ChartLegendItem">
                            <Grid x:Name="PART_MainContainer" HorizontalAlignment="Stretch" VerticalAlignment="Top" Margin="0,0,5,0">
                                <Path x:Name="PART_LegendItemMarker"
                                      Height="20"
                                      Width="100"
                                      Style="{TemplateBinding ItemStyle}"
                                      Stretch="Fill">
                                    <Path.Data>
                                        <PathGeometry x:Name="PART_ItemMarkerGeometry" />
                                    </Path.Data>
                                </Path>
                                <CheckBox IsChecked="True"  x:Name="checkbox1"
                                          VerticalAlignment="Center"
                                          Margin="2,0"
                                          Content="{TemplateBinding Label}"
                                          Foreground="{TemplateBinding Foreground}"
                                          Command="{Binding Path=ChangeSeriesVisibilityCommand, Source={StaticResource ViewModel}}"
                                          CommandParameter="{TemplateBinding Label}"
                                          />
                        </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </UserControl.Resources>
     
  2. Answer
    Petar Kirov
    Admin
    Petar Kirov avatar
    425 posts

    Posted 01 Oct 2012 Link to this post

    Hello Peiyang,

      I suggest that you review the msdn documentation and more specifically this topic where it is shown how to access control-template generated elements.
    Please note that this is a general question which is not directly related to our controls and the implementation of this code is out of our support scope.
    If you have any more frustrations/questions on this - please ask them in the official Microsoft Silverlight forums or in StackOverflow.
     
    Kind regards,
    Petar Kirov
    the Telerik team

    Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

  3. DevCraft banner
Back to Top