Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Problem description: Animating an inherited property doesn't work in some cases. It works if the host element has had an inherited property set directly, even one different from the one being animated. It (sometimes) works if a second inherited property is already being animated. Sometimes it doesn't work until you do some other action, after which it works. In other cases, it may not work at all. There is no simple pattern.
The attached repro declares a style for TextBlock that contains triggers to animate its Foreground and LineHeight properties (both are inheritable). It displays four instances of TextBlock using the style, but with different initial settings for the properties. Each comes with buttons to activate the two triggers. All four should work the same way, but the repro illustrates that they depend on outside factors or previous behavior. (The repro demonstrates four interesting cases, but it doesn't illustrate all the bizarre ways this can fail.)
Expected behavior: The "Trigger FG" button animates the TextBlock's Foreground, causing its text to turn red.
Actual behavior: The "No Inheritance" and "Inherit Foreground" instances don't work initially, but start working after you click the "Trigger LH" button. The "Inherit LineHeight" instance doesn't work at all. The "Set LineHeight" instance works correctly.
Remarks: This bug is responsible for the failure of some test cases in .NET 4.0+, including one that recently arose while testing an unrelated servicing fix. The test cases aren't testing this scenario directly, but they make runtime choices that occasionally stumble across the bug. For a while it appeared that the failure happened only on Win8.1 + .NET 4.7.2 (and only when no debugger was attached), but it turns out that the OS, .NET version, debugger, etc. all influence the runtime choices, and only rarely produce a failing case.