如何在运行时覆盖属性 [英] how to override properties at run time

查看:75
本文介绍了如何在运行时覆盖属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个DataGrid,它在设计时本身将RowBackGround和交替的RowBackGround设置为黑色.
作为事件触发主题更改的一部分,我想包括要在运行时设置的AlternatingRowBackGround和RowBackGround(以其他颜色设置),但是它没有发生.它需要一些替代方法来解决这个问题
在此先感谢

I have DataGrid whose RowBackGround and alternating RowBackGround set to black at the design time itself.
an as the part of event triggered theme change I want to include AlternatingRowBackGround and RowBackGround to be set during run time (to some other color) but it is not taking place.it require some overrid how i can aproach this
thanks in advance

推荐答案

出了什么问题? MyDataGrid.Rowbackground = someBruh;怎么了?

请参阅:
http://msdn.microsoft. com/en-us/library/system.windows.controls.datagrid.rowbackground%28v = vs.95%29.aspx [ http://beta.codeproject.com/Messages/4078126/Datagrid-Row-background-binding-issue.aspx [ ^ ].



请在他的主题中查看Espen的回答和我们的评论.记下Espen关于样式的注释,我提到了您可能会觉得有用的文章:
WPF主题和外观引擎 [
What''s the problem? What''s wrong with MyDataGrid.Rowbackground = someBruh;?

Please see:
http://msdn.microsoft.com/en-us/library/system.windows.controls.datagrid.rowbackground%28v=vs.95%29.aspx[^].

See also this CodeProject thread: http://beta.codeproject.com/Messages/4078126/Datagrid-Row-background-binding-issue.aspx[^].



Please see the answer by Espen and our comments in his thread. Crediting Espen''s note on the styles, I mentioned the article which you could find useful:
WPF Themes and Skins Engine[^].

—SA


看看:样式可以被继承 [ ^ ].

为您的应用程序创建新样式,该样式继承自您要与您的应用程序一起使用的样式,并应用适当的设置器.这样,您将不需要处理应用程序中的任何事件.

WPF DataGrid实用示例 [
Have a look at:Styling Microsoft’s WPF datagrid[^]

Rembemer that styles can be inherited[^] too.

Create new styles for your application that inherits from the ones you want to work with your application and apply appropriate setters. This way you will not need to handle any events in your application.

WPF DataGrid Practical Examples[^] provides a good introduction to the WPF DataGrid.

Best regards
Espen Harlinn


这篇关于如何在运行时覆盖属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆