2010-07-19 37 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作爲公共屬性公開。