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.
精彩评论