全部, 我在“输出”窗口中看到以下绑定(bind)警告。有人可以在这里解释 Binding 的问题吗?我在我的 ViewModel 中为 ProgressValue' 设置了几个值。但仅为“ProgressValue”设置最终值 100,如下所示。
System.Windows.Data Warning: 95 : BindingExpression (hash=58496944): Got PropertyChanged event from ExportControls (hash=6385044)
System.Windows.Data Warning: 95 : BindingExpression (hash=58496944): Got PropertyChanged event from ExportControls (hash=6385044)
System.Windows.Data Warning: 95 : BindingExpression (hash=58496944): Got PropertyChanged event from ExportControls (hash=6385044)
System.Windows.Data Warning: 95 : BindingExpression (hash=58496944): Got PropertyChanged event from ExportControls (hash=6385044)
System.Windows.Data Warning: 95 : BindingExpression (hash=58496944): Got PropertyChanged event from ExportControls (hash=6385044)
System.Windows.Data Warning: 95 : BindingExpression (hash=58496944): Got PropertyChanged event from ExportControls (hash=6385044)
System.Windows.Data Warning: 95 : BindingExpression (hash=58496944): Got PropertyChanged event from ExportControls (hash=6385044)
System.Windows.Data Warning: 95 : BindingExpression (hash=58496944): Got PropertyChanged event from ExportControls (hash=6385044)
System.Windows.Data Warning: 95 : BindingExpression (hash=58496944): Got PropertyChanged event from ExportControls (hash=6385044)
System.Windows.Data Warning: 95 : BindingExpression (hash=58496944): Got PropertyChanged event from ExportControls (hash=6385044)
System.Windows.Data Warning: 95 : BindingExpression (hash=58496944): Got PropertyChanged event from ExportControls (hash=6385044)
System.Windows.Data Warning: 95 : BindingExpression (hash=58496944): Got PropertyChanged event from ExportControls (hash=6385044)
System.Windows.Data Warning: 95 : BindingExpression (hash=58496944): Got PropertyChanged event from ExportControls (hash=6385044)
System.Windows.Data Warning: 95 : BindingExpression (hash=58496944): Got PropertyChanged event from ExportControls (hash=6385044)
System.Windows.Data Warning: 95 : BindingExpression (hash=58496944): Got PropertyChanged event from ExportControls (hash=6385044)
System.Windows.Data Warning: 95 : BindingExpression (hash=58496944): Got PropertyChanged event from ExportControls (hash=6385044)
System.Windows.Data Warning: 95 : BindingExpression (hash=58496944): Got PropertyChanged event from ExportControls (hash=6385044)
System.Windows.Data Warning: 95 : BindingExpression (hash=58496944): Got PropertyChanged event from ExportControls (hash=6385044)
System.Windows.Data Warning: 95 : BindingExpression (hash=58496944): Got PropertyChanged event from ExportControls (hash=6385044)
System.Windows.Data Warning: 95 : BindingExpression (hash=58496944): Got PropertyChanged event from ExportControls (hash=6385044)
System.Windows.Data Warning: 101 : BindingExpression (hash=58496944): GetValue at level 0 from ExportControls (hash=6385044) using RuntimePropertyInfo(ProgressValue): '100'
System.Windows.Data Warning: 80 : BindingExpression (hash=58496944): TransferValue - got raw value '100'
System.Windows.Data Warning: 89 : BindingExpression (hash=58496944): TransferValue - using final value '100'
我的代码如下所示。它在 Styles.xaml 中定义。
<ProgressBar IsIndeterminate="False"
Value="{Binding ProgressValue,
UpdateSourceTrigger=PropertyChanged,
Mode=TwoWay,
diag:PresentationTraceSources.TraceLevel=High}"
x:Name="ExportProgressBar"
Visibility="Collapsed"
VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
Background="Transparent"
BorderThickness="0"
Foreground="{StaticResource HighlightBlueBrush}"
/>
在我的 View 模型中,我更新了如下所示的值。
Dispatcher.CurrentDispatcher.Invoke(new Action(() =>
{
export.ProgressValue = pMeter;
}));
最佳答案
BradleyDotNET 是对的。
您已将 PresentationTraceSources.TraceLevel 设置为高。这将导致打印有关绑定(bind)的大量信息。
关于c# - WPF 绑定(bind)警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27950605/