none
How to access a named control inside a XAML DataTemplate (using XAML) RRS feed

  • Question

  • Hello All,

    I have a situation where I need to access a data template control from  parent control. following is the code snipped.

    Look at the Bold Sections.

     <TabControl Margin="5,0,0,0" 
                      Grid.Column="1" 
                      ItemsSource="{Binding Workspaces}" 
                      ItemTemplateSelector="{StaticResource SettingsTemplateSelector}" 
                      SelectedIndex="0">
              <inter:Interaction.Behaviors>
                <interactivity:TabControlService>
                    <interactivity:TabControlService.TabCloseButton>
                        <Binding ElementName="CloseButton"/>
                    </interactivity:TabControlService.TabCloseButton>
                </interactivity:TabControlService>
              </inter:Interaction.Behaviors>
            <TabControl.ItemTemplate>
              <DataTemplate>
                <StackPanel Orientation="Horizontal">
                  <TextBlock Text="{Binding Header}"></TextBlock>
                  <Button Name="CloseButton" Content="X" Margin="5,0,0,0"></Button>
                </StackPanel>
              </DataTemplate>
            </TabControl.ItemTemplate>
          </TabControl>

     In the above markup,  I need to bind the Button named CloseButton to TabcontrolService's TabCloseButton property which is a dependency property. I need to do it through XAML only, no code behind code.

    Please Help me somebody, waiting for your valuable solutions.

    Regards
    Debasish


    Debasish Das Software Developer. gloStream Inc.

    Monday, July 22, 2013 12:21 PM

Answers

All replies