WPF 绑定不适用于 TextBlock 中的前景属性

问题描述 投票:0回答:1

我有以下代码来设置前景属性


    TextBlock label = new TextBlock() { Style = LabelStyle };
    Binding binding = new Binding(LabelColor) { Source = dataContextProperty };
    label.SetBinding(TextBlock.ForegroundProperty, binding);

请注意,LabelColor 是一个画笔。 如果我设定的话,

label.SetBinding(TextBlock.BackgroundProperty, binding)

它起作用了。那么为什么它不仅仅适用于前台呢?

c# wpf xaml textblock
1个回答
0
投票

我也有同样的问题,请问你找到答案了吗?

© www.soinside.com 2019 - 2024. All rights reserved.