【发布时间】:2015-09-24 19:20:03
【问题描述】:
【问题讨论】:
标签: wpf progress-bar
【问题讨论】:
标签: wpf progress-bar
您可以定义进度条的 ValueChanged 事件并将值设置为弹出窗口。请参考以下示例:
//Define a popup in your code, add a Label to it; the below code could be added to the
//ctor/any other block which would be invoked prior to the ValueChanged event.
//Please ensure Popup is declared such that it is visble/accessible in any of the
//functions - in this case, the ValueChanged Event & where you decide to add label &
//placement values to it.
Popup pop = new Popup();
Label lbl = new Label();
pop.Child = lbl;
pop.Placement = placementMode.Relative;
pop.PlacementTarget = progressBar;//assuming name of ProgressBar is progressbar
private void ProgressBar_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
pop.IsOpen = true;
//Set the horizontal offset of Popup in accordance to dimensions of your progress bar
(pop.Child as Label).Content = progressBar.Value.ToString();
Thread.Sleep(100);
pop.IsOpen = false;
}
注意:如果您需要根据屏幕截图的弹出外观和感觉,则必须修改标签的模板。
【讨论】: