Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Coded UI - Cannot playback WPF DataGrid

$
0
0

I am learning Coded UI automation testing. Now I have a problem to playback when I click the second row on the WPF DataGrid, “bill”.  Here is my code. I tried to modify product code. But I just couldn’t do it. I am looking for a fix on product code, not on the coded UI code.  Here is my product code. Thanks in advance.

MainWindow.xaml file

<Window x:Class="WpfApplication5.MainWindow"

       xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

       xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

       Title="MainWindow" Height="350" Width="525">

   <Grid>

       <StackPanel>

           <DataGrid x:Name="MyGrid" Height="200" AutomationProperties.AutomationId="xss" ItemsSource="{Binding persons}"

         CanUserReorderColumns="True" CanUserResizeColumns="True"

         CanUserResizeRows="False" CanUserSortColumns="True" SelectedItem="fff" >

            

               <DataGrid.RowStyle>

                   <Style TargetType="{x:Type DataGridRow}" >

                       <Setter x:Name="MyGridItem" Property="AutomationProperties.AutomationId" Value ="LightBlue" />

                     

                   </Style>

                  

               </DataGrid.RowStyle>

            

           </DataGrid>

       </StackPanel>

   </Grid>

</Window>

MainWindow.xaml.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows;

using System.Windows.Controls;

using System.Windows.Data;

using System.Windows.Documents;

using System.Windows.Input;

using System.Windows.Media;

using System.Windows.Media.Imaging;

using System.Windows.Navigation;

using System.Windows.Shapes;

using System.Windows.Forms;

namespace WpfApplication5

{

   publicclassPerson

   {

       public Person(string firstName, string lastName,Boolean isMVP )

       {

           FirstName = firstName;

           LastName = lastName;

           IsMVP = isMVP;

       }

       publicstring FirstName {get;set; }

       publicstring LastName {get;set; }

       publicBoolean IsMVP {get;set; }

   }

   publicpartialclassMainWindow :Window

   {

       public MainWindow()

       {

           InitializeComponent();

        

           var persons =newList<Person>

               {

                   newPerson("Steve","cccc",true),

                   newPerson("Bill","Gates",true),

                   newPerson("Dan","Brown",true),

                   newPerson("Barack","Obama",true)

               };

           MyGrid.ItemsSource = persons;

     

       }

  

   }

}


Lisa


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>