public virtual UIElement GenerateCell() { var cell = CellTemplate == null ? null : CellTemplate.LoadContent() as UIElement; cell = cell ?? new TextBlock(); SetColumn(cell, this); var element = cell as FrameworkElement; if (element != null) { var dataPath = string.IsNullOrWhiteSpace(DataMember) ? "(0).Item" : "(0).Item." + DataMember; element.SetBinding(FrameworkElement.DataContextProperty, new Binding { Path = new PropertyPath(dataPath, LiteRow.RowProperty.DependencyProperty), Source = element, Mode = BindingMode.OneWay }); } var text = cell as TextBlock; if (text != null) { text.SetBinding(TextBlock.TextProperty, new Binding("DataContext") { Source = text, Mode = BindingMode.OneWay }); } return(cell); }
private FrameworkElement GenerateElement(object childData) { if (CellTemplate != null) { FrameworkElement element = CellTemplate.LoadContent() as FrameworkElement; element.DataContext = childData; return(element); } else //we are going to make a ToString() of the element the user tries to show: { TextBlock textBlock = new TextBlock(); textBlock.Text = childData.ToString(); return(textBlock); } }