开发者

only one setter of the syle of a wpf datagrid is assigned. how to enable other setter?

i have added 2 setters to a style and assigned that style to a wpf datagridtemplatecolumn cell style. but one of them is assigned. another one is not assigned. any one know how to solve this?

 Style st = new Style();
 Setter sett2 = new Setter
 {
     Property = TextBox.BackgroundProperty,
     Value = Brushes.Yellow
 };
 Setter sett =开发者_开发知识库 new Setter
 {
     Property = TextBox.IsEnabledProperty,
     Value = false
 };
 st.Setters.Add(sett);
 st.Setters.Add(sett2);
 col.CellStyle = st;

Isenabled property is set false. but colur is still gray.


Cannot reproduce this (i.e. the background indeed becomes yellow).

If you explicitly set the background on the TextBox/TextBlock inside the template this style will not affect it due to dependency property value precedence. There could be other causes but there is not enough context to go by, for me at least.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜