gpt4 book ai didi

c# - WPF如何在进度条上显示文字

转载 作者:太空宇宙 更新时间:2023-11-03 22:46:01 50 4
gpt4 key购买 nike

我有一个 DataGrid,其中一列用于显示下载百分比。下面是我的代码:

<DataGridTemplateColumn Header="Percent" IsReadOnly="True" Width="*">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<DockPanel>
<Button Margin="5,0,0,0" DockPanel.Dock="Right" VerticalContentAlignment="Center" Style="{StaticResource BasicButtonStyle}" Command="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type DataGrid}}, Path=DataContext.StopButtonClickCommand}" >
<Image Height="12" Source="/Client;component/Resources/Images/stop.png" />
</Button>
<ProgressBar Value="{Binding Path=Percent, Mode=OneWay}" Minimum="0" Maximum="100" />
<TextBlock Text="{Binding Path=Percent , StringFormat={}{0}%}" HorizontalAlignment="Center" ></TextBlock>
</DockPanel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>

我想在进度条上显示文字,同时让按钮保持在右边。我应该如何修改我的代码?

最佳答案

将 ProgressBar 和 TextBlock 放在一个容器(Grid)中

<Grid>
<ProgressBar Value="{Binding Path=Percent, Mode=OneWay}" Minimum="0" Maximum="100" />
<TextBlock Text="{Binding Path=Percent , StringFormat={}{0}%}" HorizontalAlignment="Center" />
</Grid>

关于c# - WPF如何在进度条上显示文字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49894696/

50 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com