Topic | Value |
---|---|
Id | WPF0041 |
Severity | Warning |
Enabled | True |
Category | WpfAnalyzers.DependencyProperty |
Code | WPF0041SetMutableUsingSetCurrentValue |
Prefer setting mutable dependency properties using SetCurrentValue.
Setting the value of dependency properties using the CLR accessor calls SetValue(Property, value). This will kill one-way bindings on the property. This rule is probably most relevant in library code where accidentally setting a value can be a hard to track down bug.
Use SetCurrentValue(Property, value)
Configure the severity per project, for more info see MSDN.
#pragma warning disable WPF0041 // Set mutable dependency properties using SetCurrentValue.
Code violating the rule here
#pragma warning restore WPF0041 // Set mutable dependency properties using SetCurrentValue.
Or put this at the top of the file to disable all instances.
#pragma warning disable WPF0041 // Set mutable dependency properties using SetCurrentValue.
[System.Diagnostics.CodeAnalysis.SuppressMessage("WpfAnalyzers.DependencyProperty",
"WPF0041:Set mutable dependency properties using SetCurrentValue.",
Justification = "Reason...")]