How Can I get a Control inside DataGrid RowDetailTemplate RRS feed

  • Question

  • I have this Xaml Code and I want to get the DataGrid "dgRemplacement", I try using Name but it doesn't work also with Uid.

                    <Grid Background="#FF4088C0" Name="DetailGrid">
                     <TabItem Header="Detaille">                
                                <TabItem Header="Intervention">                               
                                <TabItem Header="Detaille Intervention">                
                                <TabItem Header="Remplacement">
                                    <Grid Background="#FFE5E5E5">
                                        <DataGrid Name="dgRemplacement" x:Uid="DataGrid1">
                                                <DataGridTextColumn Header="Article(Serie)" Binding="{Binding Designation}"/>
                                                <DataGridTextColumn Header="Qte" Binding="{Binding Qte}"/>

    private void dgBILigne_RowDetailsVisibilityChanged(object sender, DataGridRowDetailsEventArgs e)
                TabControl tc = (e.DetailsElement as Grid).Children[0] as TabControl;
                TabItem ti = tc.Items[3] as TabItem;

    I have succeeded to get the TabItem
    lundi 18 avril 2011 08:40


  • Bonjour ,


    Essayer le code suivant pour retrouver votre DataGrid :


    public static DependencyObject ResearchType(DependencyObject element, Type researchType)
          if (element == null) return null;
          if (element.GetType() == researchType) return element;
          DependencyObject parent = VisualTreeHelper.GetParent(element);
          return ResearchType(parent, researchType);
        private void dgBILigne_RowDetailsVisibilityChanged(object sender, DataGridRowDetailsEventArgs e)
          ResearchType(e.DetailsElement as Grid, typeof(DataGrid));

    Cordialement, Pascal.

    Développeur Wpf/SilverLight/WinPhone7

    mardi 26 avril 2011 19:23