Вы можете добавить элемент управления как TextBlock
, используя FrameworkElementFactory
. Затем вы можете добавить TextBlock
к VisualTree DataTemplate
. Вот так:
//Create binding object and set as mode=oneway
Binding binding = new Binding();
binding.Path = new PropertyPath("SomePropertyPathName");
binding.Mode = BindingMode.OneWay;
//get textblock object from factory and set binding
FrameworkElementFactory textElement = new FrameworkElementFactory(typeof(TextBlock));
textElement.SetBinding(TextBlock.TextProperty, binding);
//apply textblock to datatemplate
dataTemplate.VisualTree = textElement;