Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ComboBox to DataGrid in WpfTestApplication #217

Merged
merged 4 commits into from
Feb 9, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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