Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Ensure BindingContext is properly passed to CreateDefault in UWP ListView #259

Merged
merged 1 commit into from
Jul 18, 2016
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Text;
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;

namespace Xamarin.Forms.Controls.Issues
{
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Bugzilla, 41205, "UWP CreateDefault passes string instead of object")]
public class Bugzilla41205 : ContentPage
{
public class CustomListView : ListView
{
protected override Cell CreateDefault(object item)
{
if (item is ViewModel)
return base.CreateDefault("Pass");
return base.CreateDefault("Fail");
}
}

public Bugzilla41205()
{
var listView = new CustomListView
{
ItemsSource = new []
{
new ViewModel(),
new ViewModel(),
}
};

Content = listView;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla40955.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla41078.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla40998.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla41205.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla41424.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla42074.cs" />
<Compile Include="$(MSBuildThisFileDirectory)CarouselAsync.cs" />
Expand Down
7 changes: 3 additions & 4 deletions Xamarin.Forms.Platform.WinRT/CellControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,13 @@ void SetCell(object newContext)
}
else
{
string textContent = newContext.ToString();

IListViewController listViewController = lv;
var defaultContext = newContext;

if (isGroupHeader)
textContent = listViewController.GetDisplayTextFromGroup(newContext);
defaultContext = listViewController.GetDisplayTextFromGroup(newContext);

cell = listViewController.CreateDefaultCell(textContent);
cell = listViewController.CreateDefaultCell(defaultContext);
}

// A TableView cell should already have its parent,
Expand Down