Select to view content in your preferred language

Assecing Control template items codebehind

1501
1
06-26-2012 06:17 AM
bayramüçüncü
Deactivated User
I have a control template in page Layout as following.

<Grid x:Name="LayoutRoot">
        <Grid.Resources>
        <ControlTemplate x:Key="myTemplate" TargetType="esri:MapTip">
                <Border CornerRadius="10" Background="#DDFFEEEE" BorderThickness="4" BorderBrush="#99FF0000">
                    <StackPanel Background="#DDFFFFFF">

                      <sdk:TabControl Height="180" Margin="5"  Name="tabControl1"  Width="300">      
                               <sdk:TabItem Header="Info" Name="infoTab">
                                 
                               <TextBlock x:Name="cityInfoTxt" Tag="{Binding [City_ID]}"/>    
           
                               </sdk:TabItem>
                        </sdk:TabControl>
                    </StackPanel>
                </Border>
            </ControlTemplate>


In code behind how can I access the  <TextBlock x:Name="cityInfoTxt" /> ??

I tried this,
       
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            var te = this.LayoutRoot.Resources["myTemplate"] as ControlTemplate;
            
        }


but can not access the textblock in the tab control.
0 Kudos
1 Reply
DominiqueBroux
Esri Frequent Contributor
You can't access by code to inner elements of a control template.

All you can do by code is to manipulate your control template as a string and then create the controltemplate object using XamlReader.
0 Kudos