ProgressBar作为DataGridView行的背景 [英] ProgressBar as background for DataGridView rows
本文介绍了ProgressBar作为DataGridView行的背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以将ProgressBar设置为DataGridView行的背景?还是从左到右仅对行的一部分进行着色?我有代表一些动态变化的数据的行,我需要以某种方式显示进度。我想将整个行的背景用作进度条,该怎么做?
Is it possible to set ProgressBar as background for DataGridView row? Or color only part of the row from left to right? I have rows that represent some dynamically changing data and I need to show that progress somehow. I want to use an entire row background as a progress bar, how can I do that?
推荐答案
如果要使用整行,最好覆盖 DataGridRow
的默认模板,使用 DataGrid.RowStyle
,然后在其他内容下方放置一个ProgressBar,例如
If you want to use the entire row it might be best to override the default template of the DataGridRow
using the DataGrid.RowStyle
, then you lay a ProgressBar below the other content, e.g.
<Setter
Property="Template">
<Setter.Value>
<ControlTemplate
TargetType="{x:Type DataGridRow}">
<Border
x:Name="DGR_Border"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
SnapsToDevicePixels="True">
<Grid>
<ProgressBar
Value="{Binding SomeProperty}"
Minimum="0"
Maximum="100" />
<!-- Rest of default template here -->
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
这篇关于ProgressBar作为DataGridView行的背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文