Silverlight 数据网格发光
我正在尝试想出一种方法来使数据网格中的单个单元格发光。
我知道你可以将这样的 dropshadoweffect 应用到整个网格:
[data:DataGrid.Effect>
[DropShadowEffect BlurRadius="100" ShadowDepth="0" Color="Red"/>
[/data:DataGrid.Effect>
但我真正想做的是当值 >= 到 100 时让单个单元格发出红色光。对小麦进行排序有点视觉效果来自大网格的谷壳。
I'm trying to think of a way to make an individual cell within a datagrid glow.
I know that you can apply a dropshadoweffect like this to the whole grid:
[data:DataGrid.Effect>
[DropShadowEffect BlurRadius="100" ShadowDepth="0" Color="Red"/>
[/data:DataGrid.Effect>
but what I really want to do is have the individual cell glow red when the value is >= to 100. It's a bit of a visual niceness to sort the wheat from the chaff of a large grid.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不久前我有一个类似的需求,我解决如下:
DataGrid当然可以模板化,所以基本上我如下模板化列,然后有一个转换器根据绑定到该单元格的数据绘制我的小部件的背景。
看一下背景绑定如何使用 MiniStatusLightConverter。
这是转换器,根据您的情况,您将检查该值是否 >= 100。
>
命名空间 MyProject.Converters
{
公共类 StatusToBrushConverter :IValueConverter
{
#region IValueConverter 的实现
}
我
希望这至少能给你带来想法。我尝试的另一种方法是创建一个用户控件并将其放在 CellTemplate 上而不仅仅是边框上,但我遇到了问题,用户对我的此功能大喊大叫。它有效并且用户很高兴,这也很重要。
我希望它有帮助
I had a similar requirement not long ago which I solved as follows:
DataGrids can be templated of course, so basically I templated the Columns as follows and then had a Converter that painted the background of my widget according to the data bound to this cell.
Have a look at the background binding how it uses the MiniStatusLightConverter.
Here is the converter, in your case you will check if the value is >= 100.
>
namespace MyProject.Converters
{
public class StatusToBrushConverter : IValueConverter
{
#region Implementation of IValueConverter
}
}
I hope at least this brings you ideas. Another approach I tried was create an user control and put it on the CellTemplate rather than just the Border but I had issues and users were screaming at me for this functionality. It works and users are happy, that counts too.
I hope it helps