Ejemplo n.º 1
0
        protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem)
        {
            var binding = new Binding(((Binding)Binding).Path.Path);

            binding.Source = dataItem;
            var content = new ContentControl();

            content.ContentTemplate = (DataTemplate)cell.FindResource(TemplateName);
            content.SetBinding(ContentControl.ContentProperty, binding); return(content);
        }
Ejemplo n.º 2
0
        protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem)
        {
            var col = cell.Column as ExtendedTemplateColumn;

            if (col.CellTemplate != null)
            {
                return(base.GenerateElement(cell, dataItem));
            }

            var binding = new Binding(this.FieldName)
            {
                Source = dataItem
            };
            var content = new ContentControl {
                ContentTemplate = (DataTemplate)cell.FindResource("CustomTemplate")
            };

            content.SetBinding(ContentControl.ContentProperty, binding);
            col.IsDefaultBinding = true;
            return(content);
        }