2010-07-19 104 views
4

在GirdView中,某些列的文本应该对齐到右侧。 为此,我创建了一个DataTemplate,其中包含一个TextBlock。获取从FrameworkElementFactory绑定

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

回答

0

我有同样的问题,所以我将TextAlignmentProperty作为公共属性公开。