In a GirdView the text of some columns sould be aligned to the r开发者_开发百科ight. To do that I create a DataTemplate, which contains a TextBlock.
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;
In an other class I have to access the Bindings of my GridViewColumns. How can I access the Binding of this column?
I had the same issue, so I exposed the TextAlignmentProperty as a public property.
精彩评论