开发者

Get Binding from a FrameworkElementFactory

开发者 https://www.devze.com 2023-01-07 17:51 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消