C# 带文本的WPF DataGrid Progressbar

C# 带文本的WPF DataGrid Progressbar,c#,wpf,datagrid,progress-bar,C#,Wpf,Datagrid,Progress Bar,我环顾四周,想找到解决我问题的方法,但我相信,对于这个问题,很多可用的方法都是冗长的 基本上,我在Datagrid单元中有一个Progressbar,它可以正常工作。但是,我现在想将文本放在Progressbar中以显示实际百分比。 这是怎么做到的 到目前为止我的代码 <DataGridTemplateColumn Header="Percentage Downloaded" Width="5*"> <DataGridTemplateCol

我环顾四周,想找到解决我问题的方法,但我相信,对于这个问题,很多可用的方法都是冗长的

基本上,我在Datagrid单元中有一个Progressbar,它可以正常工作。但是,我现在想将文本放在Progressbar中以显示实际百分比。 这是怎么做到的

到目前为止我的代码

        <DataGridTemplateColumn Header="Percentage Downloaded" Width="5*">
           <DataGridTemplateColumn.CellTemplate>
              <DataTemplate>
                 <ProgressBar Value="{Binding Path=PercentageDownloaded, Mode=OneWay}" Minimum="0" Maximum="100" />
              </DataTemplate>
           </DataGridTemplateColumn.CellTemplate>
        </DataGridTemplateColumn>

为了表示我的努力,我尝试在进度条中使用tag属性,并使用textblock,但都失败了

非常感谢

*解决方案*


GiangregorioC提供的解决方案是有效的,因为我没有意识到可以将标记放在DataGridCellTemplate中

您可以将进度条和文本块放入网格中,如下所示:

<Grid>
    <ProgressBar />
    <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" />
</Grid>


textblock将出现在progressbar上。

事实上,我在大约5秒钟前才看到该代码,但是您可以将其放入DataGridCellTemplate中吗?如果我尝试一下,可能会更快…是的,您可以在数据模板中添加网格。