summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.WinRT
diff options
context:
space:
mode:
authorSamantha Houts <samantha@teamredwall.com>2016-08-11 02:31:45 -0700
committerRui Marinho <me@ruimarinho.net>2016-08-11 10:31:45 +0100
commit69e9152f345a4a001282ddf60b19cc0a6b7d05e5 (patch)
treee513166642a2470e2b13bc43987d89507742afd8 /Xamarin.Forms.Platform.WinRT
parent1823c1ad1463aa30deb289bc9538a68a5316164b (diff)
downloadxamarin-forms-69e9152f345a4a001282ddf60b19cc0a6b7d05e5.tar.gz
xamarin-forms-69e9152f345a4a001282ddf60b19cc0a6b7d05e5.tar.bz2
xamarin-forms-69e9152f345a4a001282ddf60b19cc0a6b7d05e5.zip
[Win] Set BindingContext for default cell (#289)
* Revise 41205 test case to use binding * [Win] Set BindingContext for default cell * [Win] SetInheritedBindingContext for Cell
Diffstat (limited to 'Xamarin.Forms.Platform.WinRT')
-rw-r--r--Xamarin.Forms.Platform.WinRT/CellControl.cs12
1 files changed, 7 insertions, 5 deletions
diff --git a/Xamarin.Forms.Platform.WinRT/CellControl.cs b/Xamarin.Forms.Platform.WinRT/CellControl.cs
index 66be8262..eb06e688 100644
--- a/Xamarin.Forms.Platform.WinRT/CellControl.cs
+++ b/Xamarin.Forms.Platform.WinRT/CellControl.cs
@@ -215,32 +215,34 @@ namespace Xamarin.Forms.Platform.WinRT
{
bool isGroupHeader = IsGroupHeader;
DataTemplate template = isGroupHeader ? lv.GroupHeaderTemplate : lv.ItemTemplate;
+ object bindingContext = newContext;
if (template is DataTemplateSelector)
{
- template = ((DataTemplateSelector)template).SelectTemplate(newContext, lv);
+ template = ((DataTemplateSelector)template).SelectTemplate(bindingContext, lv);
}
if (template != null)
{
cell = template.CreateContent() as Cell;
- cell.BindingContext = newContext;
}
else
{
IListViewController listViewController = lv;
- var defaultContext = newContext;
if (isGroupHeader)
- defaultContext = listViewController.GetDisplayTextFromGroup(newContext);
+ bindingContext = listViewController.GetDisplayTextFromGroup(bindingContext);
- cell = listViewController.CreateDefaultCell(defaultContext);
+ cell = listViewController.CreateDefaultCell(bindingContext);
}
// A TableView cell should already have its parent,
// but we need to set the parent for a ListView cell.
cell.Parent = lv;
+ // Set inherited BindingContext after setting the Parent so it won't be wiped out
+ BindableObject.SetInheritedBindingContext(cell, bindingContext);
+
// This provides the Group Header styling (e.g., larger font, etc.) when the
// template is loaded later.
cell.SetIsGroupHeader<ItemsView<Cell>, Cell>(isGroupHeader);