Skip to content

Commit

Permalink
Merge pull request #217 from ilya-murzinov/TestAppModification
Browse files Browse the repository at this point in the history
Added ComboBox to DataGrid in WpfTestApplication
  • Loading branch information
JakeGinnivan committed Feb 9, 2014
2 parents aa23158 + b52cea3 commit 533934b
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 19 deletions.
15 changes: 14 additions & 1 deletion src/TestApplications/WpfTestApplication/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,20 @@
</StackPanel>
</TabItem>
<TabItem Header="Data Grid">
<DataGrid x:Name="DataGridControl" AutoGenerateColumns="True" ItemsSource="{Binding Path = TestItems}"/>
<DataGrid x:Name="DataGridControl" AutoGenerateColumns="False" CanUserAddRows="false" ItemsSource="{Binding States}">
<DataGrid.Columns>
<DataGridTextColumn Header="Id" Binding="{Binding Id}"/>
<DataGridTextColumn Header="Contents" Binding="{Binding Contents}"/>
<DataGridTextColumn Header="Description" Binding="{Binding Description}"/>
<DataGridTemplateColumn Header="Combobox" Width="*">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ComboBox ItemsSource="{Binding ComboboxItems}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
</TabItem>
</TabControl>
<GroupBox Header="Scenarios" Grid.Row="3" Grid.Column="1" AutomationProperties.AutomationId="ScenariosPane">
Expand Down
65 changes: 58 additions & 7 deletions src/TestApplications/WpfTestApplication/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,50 @@ namespace WpfTestApplication
public partial class MainWindow
{
private bool controlsDisabled;
private readonly ObservableCollection<State> states = new ObservableCollection<State>();

public MainWindow()
{
DataContext = this;

InitializeComponent();

var treeViewItem = new TreeViewItem { Header = "Lots Of Children" };
foreach (var i in Enumerable.Range(1, 50))
{
treeViewItem.Items.Add(new TreeViewItem { Header = "Child" + i });
}

TreeView.Items.Add(treeViewItem);

states.Add(new State()
{
Id = "1",
Contents = "Item1",
Description = "Simple item 1",
ComboboxItems = new ObservableCollection<string>(DataGridComboboxItems)
});

states.Add(new State()
{
Id = "2",
Contents = "Item2",
Description = "",
ComboboxItems = new ObservableCollection<string>(DataGridComboboxItems)
});

states.Add(new State()
{
Id = "3",
Contents = "Item3",
Description = "",
ComboboxItems = new ObservableCollection<string>(DataGridComboboxItems)
});
}

public ObservableCollection<State> States
{
get { return states; }
}

public ObservableCollection<string> ListItems
Expand Down Expand Up @@ -159,16 +192,34 @@ private void ClickMe_OnClick(object sender, RoutedEventArgs e)
AutomationProperties.SetHelpText(this, "Click Me Clicked");
}

public TestItem[] TestItems
public string[] DataGridComboboxItems
{
get
get
{
return new[]{
new TestItem {Id = 1, Contents = "Item1", Description = "Simple item 1"},
new TestItem {Id = 2, Contents = "Item2", Description = ""},
new TestItem {Id = 3, Contents = "Item3"}
};
return new[]
{
"Item1",
"Item2",
"Item3",
"Item4"
};
}

}

public class State
{
public string Id
{ get; set; }

public string Contents
{ get; set; }

public string Description
{ get; set; }

public ObservableCollection<string> ComboboxItems
{ get; set; }
}
}
}
9 changes: 0 additions & 9 deletions src/TestApplications/WpfTestApplication/TestItem.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@
<Compile Include="Scenarios\HorizontalGridSplitter.xaml.cs">
<DependentUpon>HorizontalGridSplitter.xaml</DependentUpon>
</Compile>
<Compile Include="TestItem.cs" />
<Compile Include="ListControls.xaml.cs">
<DependentUpon>ListControls.xaml</DependentUpon>
</Compile>
Expand Down
2 changes: 1 addition & 1 deletion src/TestStack.White.UITests/ControlTests/DataGridTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void CanGetAllItemsWpf()
var rows = DataGridWpfUnderTest.Rows;
Assert.Equal(3, rows.Count);
var row1 = rows.Get(0);
Assert.Equal(3, row1.Cells.Count);
Assert.Equal(4, row1.Cells.Count);
Assert.Equal("1", row1.Cells[0].Text);
Assert.Equal("Item1", row1.Cells[1].Text);
Assert.Contains("Simple", row1.Cells[2].Text);
Expand Down

0 comments on commit 533934b

Please sign in to comment.