Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: UIAutomation
Hi,
 
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">
                <local:SechduledGridRowDetailsTemplateSelector.ScheduledGridRowDetailsTemplate>
                   <DataTemplate>
                        <Button x:Name="myTestButton" Content="AddToScheduleList" HorizontalAlignment="Left" VerticalAlignment="Center" Click="Add_Click" Margin="5" />
                    </DataTemplate>
                </local:SechduledGridRowDetailsTemplateSelector.ScheduledGridRowDetailsTemplate>
            
            
                
<DataGrid x:Name="AddListView"
                      
							Height="{Binding ActualHeight, ElementName=ListHeightGrid}" VerticalAlignment="Stretch" Grid.Row="1" Margin="8"                                                   
                            ItemsSource="{Binding WorkListItems}"
                      RowDetailsTemplateSelector="{StaticResource SechduledGridRowDetailsTemplateSelector}"
                      RowDetailsVisibilityMode="VisibleWhenSelected">
 
</DataGrid.Columns>
 
...Columns are specified here
<//DataGrid.Columns>
 
</DataGrid>
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.
 
Thanks,
Priyesh
Posted 2-Jan-13 1:28am
Edited 2-Jan-13 17:19pm
v2

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 730
1 OriginalGriff 503
2 Abhinav S 278
3 thatraja 245
4 Emre Ataseven 190
0 Sergey Alexandrovich Kryukov 8,322
1 OriginalGriff 4,790
2 Peter Leow 3,784
3 Maciej Los 3,515
4 Er. Puneet Goel 3,107


Advertise | Privacy | Mobile
Web02 | 2.8.140415.2 | Last Updated 2 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid