Click here to Skip to main content
11,805,604 members (48,579 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: UI Automation

I have created a Button inside the RowDetailTemplate, and assigned this RowDetailTemplate to DataGrid. But from the UI Automation, I am not able to find this button (on selection of DataRow).

For this First I have created the Template Class in code-behind class like this:-
public class SechduledGridRowDetailsTemplateSelector : DataTemplateSelector
        public DataTemplate ScheduledGridRowDetailsTemplate { get; set; }
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
            return ScheduledGridRowDetailsTemplate;
then I am Creating ScheduledGridRowDetailsTemplate inside XAML and using it in DataGrid like this:-
<local:SechduledGridRowDetailsTemplateSelector  x:Key="SechduledGridRowDetailsTemplateSelector">
                        <Button x:Name="myTestButton" Content="AddToScheduleList" HorizontalAlignment="Left" VerticalAlignment="Center" Click="Add_Click" Margin="5" />
<DataGrid x:Name="AddListView"
							Height="{Binding ActualHeight, ElementName=ListHeightGrid}" VerticalAlignment="Stretch" Grid.Row="1" Margin="8"                                                   
                            ItemsSource="{Binding WorkListItems}"
                      RowDetailsTemplateSelector="{StaticResource SechduledGridRowDetailsTemplateSelector}"
...Columns are specified here
Now when I try to find the "myTestButton" in UI Automation code then, it is not able to find the Button on selection of any DataRow in the DataGrid.

Note:- I am able to access the DataGrid Rows in UI Automation, but not the Button inside the RowDetailTemplate.

Kindly provide the solution for this problem.Help is appreciated.

Posted 2-Jan-13 1:28am
Edited 2-Jan-13 17:19pm
(no name)502.8K

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 300
1 Richard Deeming 225
2 Sergey Alexandrovich Kryukov 170
3 ppolymorphe 125
4 CPallini 120
0 OriginalGriff 3,265
1 Maciej Los 1,990
2 KrunalRohit 1,907
3 CPallini 1,855
4 Richard MacCutchan 1,227

Advertise | Privacy | Mobile
Web03 | 2.8.151002.1 | Last Updated 2 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100