Skip to content

Grid Issue #155

@JakeGinnivan

Description

@JakeGinnivan

Automation Code

ListView pList = Container.Get<ListView>("dataGridP");
Assert.IsNotNull(pList);
ListViewRows pListRows = pList.Rows;
ListViewRow row = pListRows[0];
Assert.AreEqual("22", row.Cells[1].Text);

Window (xaml)

<Window x:Class="WpfTestAutomatedUI.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:Utils="clr-namespace:WpfTestAutomatedUI"
        Title="MainWindow" Height="350" Width="525">
    <Window.Resources>
        <Utils:ViewModel x:Key="ViewModel"/>
    </Window.Resources>
    <Grid DataContext="{Binding Source={StaticResource ViewModel}}">
        <DataGrid ItemsSource="{Binding Items}" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False"
                  IsReadOnly="True">
            <DataGrid.Columns>
                <DataGridTextColumn Binding="{Binding CountryId}" Width="*"/>
                <DataGridComboBoxColumn ItemsSource="{Binding Source={StaticResource ViewModel}, Path=Countries}" DisplayMemberPath="Name" SelectedValuePath="Id" 
                                        SelectedValueBinding="{Binding CountryId}" Width="*"/>
            </DataGrid.Columns>
        </DataGrid>
    </Grid>
</Window>

ViewModel

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WpfTestAutomatedUI
{
    class ViewModel
    {
        public List<Country> Countries { get; set; }
        public List<Item> Items { get; set; }

        public ViewModel()
        {
            Countries = new List<Country>
            {
                new Country{Id=1, Name="USA"},
                new Country{Id=2, Name="UK"},
                new Country{Id=3, Name="DE"},
                new Country{Id=4, Name="FR"},
                new Country{Id=5, Name="SP"},
            };

            Items = new List<Item>
            {
                new Item{CountryId=1},
                new Item{CountryId=2},
            };
        }
    }

    public class Item
    {
        public int CountryId { get; set; }
    }

    public class Country
    {
        public int Id { get; set; }
        public string Name { get; set; }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions