-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request picoe#887 from picoe/fix/wpf-customcell-loading-ex…
…ception Fix issue with WPF when using a custom cell on a tab.
- Loading branch information
Showing
3 changed files
with
74 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
Source/Eto.Test/Eto.Test/UnitTests/Forms/Controls/CustomCellTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
using Eto.Forms; | ||
using NUnit.Framework; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Eto.Test.UnitTests.Forms.Controls | ||
{ | ||
[TestFixture] | ||
public class CustomCellTests : TestBase | ||
{ | ||
class MyModel | ||
{ | ||
public string Text { get; set; } | ||
} | ||
|
||
class MyCustomCell : StackLayout | ||
{ | ||
public MyCustomCell() | ||
{ | ||
Orientation = Orientation.Horizontal; | ||
Items.Add(new Label { Text = "Hello!" }); | ||
var tb = new TextBox(); | ||
tb.TextBinding.BindDataContext((MyModel m) => m.Text); | ||
Items.Add(new StackLayoutItem(tb, true)); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Test for WPF crash when a grid view and custom cell is on a separate tab and you switch to it. | ||
/// </summary> | ||
[Test] | ||
public void CustomCellOnSeparateTabLoadIssue() | ||
{ | ||
TabControl tabs = null; | ||
Shown(form => | ||
{ | ||
var grid1 = new GridView { ShowHeader = false }; | ||
grid1.Columns.Add(new GridColumn { DataCell = CustomCell.Create<MyCustomCell>() }); | ||
grid1.DataStore = new List<MyModel> | ||
{ | ||
new MyModel { Text = "Item 1"}, | ||
new MyModel { Text = "Item 2"}, | ||
new MyModel { Text = "Item 3"}, | ||
}; | ||
|
||
var grid2 = new GridView { ShowHeader = false }; | ||
grid2.Columns.Add(new GridColumn { DataCell = CustomCell.Create<MyCustomCell>() }); | ||
grid2.DataStore = new List<MyModel> | ||
{ | ||
new MyModel { Text = "Item 1"}, | ||
new MyModel { Text = "Item 2"}, | ||
new MyModel { Text = "Item 3"}, | ||
}; | ||
|
||
tabs = new TabControl(); | ||
tabs.Pages.Add(new TabPage(grid1) { Text = "Tab 1" }); | ||
tabs.Pages.Add(new TabPage(grid2) { Text = "Tab 2" }); | ||
form.Content = tabs; | ||
}, () => | ||
{ | ||
tabs.SelectedIndex = 1; | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters