WPF设计带数字标签显示的进度条
2021-05-19 17:30
标签:mamicode sed alc roo translate str rmi idt val 先上图 1.xaml代码 2.附加属性 3.在设计器中使用 4.逻辑代码 5.知识点:附加属性;绑定;样式; WPF设计带数字标签显示的进度条 标签:mamicode sed alc roo translate str rmi idt val 原文地址:https://www.cnblogs.com/zhuiyishanran/p/11693125.htmlpublic static string GetPercentage(DependencyObject obj)
{
return (string)obj.GetValue(PercentageProperty);
}
public static void SetPercentage(DependencyObject obj, string value)
{
obj.SetValue(PercentageProperty, value);
}
//百分比展示
// Using a DependencyProperty as the backing store for Percentage. This enables animation, styling, binding, etc...
public static readonly DependencyProperty PercentageProperty =
DependencyProperty.RegisterAttached("Percentage", typeof(string), typeof(AttachProperty), new PropertyMetadata(""));
private void Func(object obj)
{
for (int i = 0; i 100; i++)
{
this.pro.Dispatcher.Invoke(new Action(()=> {
StyleLibrary.Core.AttachProperty.SetPercentage(pro, i.ToString() + "%");
pro.Value = i;
}));
Thread.Sleep(100);
}
}
//调用
ThreadPool.QueueUserWorkItem(Func,null);
上一篇:怎样理解window.name
下一篇:线程模块threading