4

在 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 的绑定。如何访问此列的绑定?

4

1 回答 1

0

我遇到了同样的问题,所以我将 TextAlignmentProperty 公开为公共属性。

于 2011-11-04T21:34:47.113 回答