我在列表中的进度条未在 wpf 应用程序中更新

My progress bar inside a list is not updating in wpf application

我正在开发 WPF 应用程序,ListBox 中的每个项目都有一个进度条,但是当我将它绑定到某个值时,它不会更新 UI。如果我设置一个特定的 int 值,如 45,UI 会更新。为什么它不绑定到值?

每个 ListBoxItem 都有自己的 DataContext(与视图不同)。如果 SawStatus 是视图模型的 属性,则必须将绑定更改为

Value ="{Binding DataContext.SawStatus, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListBox }"

否则,您必须提供有关 ListBox 的 ItmesSource 的更多详细信息。