← All recipes
Moderne licensed

Do not set DataContext or Style using SetCurrentValue

Recipe IDOpenRewrite.Recipes.CSharp.CodeQuality.Wpf.UseSetValueForDataContextAndStyleArtifactOpenRewrite.Recipes.CSharp.CodeQuality

DataContext and Style are inherited through the visual tree, so a value written with SetCurrentValue is discarded as soon as the inherited value changes. Replaces the call with SetValue.

Single recipecsharpcode-qualityProprietary

Usage

This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.

mod run . --recipe OpenRewrite.Recipes.CSharp.CodeQuality.Wpf.UseSetValueForDataContextAndStyle

If the recipe isn’t available locally, install it with:

mod config recipes nuget install OpenRewrite.Recipes.CSharp.CodeQuality