gpt4 book ai didi

c# - 从 FrameworkElementFactory 获取绑定(bind)

转载 作者:行者123 更新时间:2023-11-30 13:05:45 30 4
gpt4 key购买 nike

在 GirdView 中,某些列的文本应该右对齐。为此,我创建了一个 DataTemplate,其中包含一个 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;

在另一个类中,我必须访问我的 GridViewColumns 的绑定(bind)。如何访问该列的绑定(bind)?

最佳答案

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

关于c# - 从 FrameworkElementFactory 获取绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3281657/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com