Created
February 28, 2013 08:29
-
-
Save einarwh/5055185 to your computer and use it in GitHub Desktop.
Column template.
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
class FoodColumnTemplate : ITemplate | |
{ | |
private readonly Food _food; | |
public FoodColumnTemplate(Food food) | |
{ | |
_food = food; | |
} | |
public void InstantiateIn(Control container) | |
{ | |
var label = new Label(); | |
label.DataBinding += OnDataBinding; | |
container.Controls.Add(label); | |
} | |
private void OnDataBinding(object sender, EventArgs e) | |
{ | |
var label = (Label) sender; | |
var row = (DataGridItem) label.NamingContainer; | |
var canine = (ICanine) row.DataItem; | |
label.Text = canine.Eats(_food) ? "Yes" : "No"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment