在 GridView 中,某些列的文本应该向右对齐。为此,我创建了一个包含 TextBlock 的 DataTemplate。
Binding bd = new Binding("path");
FrameworkElementFactory tbContent = new FrameworkElementFactory(typeof(TextBlock));
tbContent.SetBinding(TextBlock.TextProperty, bd);
tbContent.SetValue(TextBlock.TextAlignmentProperty, TextAlignment.Right);
DataTemplate dataTemplate = new DataTemplate();
dataTemplate.VisualTree = tbContent;
myGridViewColumn.CellTemplate = dataTemplate;
在另一个类中,我必须访问我的 GridViewColumns 的绑定。如何访问此列的绑定?