dotnet / dotnet/wpf

Bindings with RalativeSource of type FindAncestor are not re-evaluated when an element moves in the visual tree

Open
#4,128 6 comments 7 reactions 0 assignees View on GitHub
.NET Framework
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

* .NET Core Version: 5.0.102
* Windows version: 10.0.19042.746
* Does the bug reproduce also in WPF for .NET Framework 4.8?: Yes

**Problem description:**
When an element containing a binding with relative source **FindAncestor** is moved in the visual tree, the binding is not re-evaluated.

**Expected behavior:**
The binding to be re-evaluated and determine the new/current relative-source ancestor.

**Minimal repro:**
Create a WPF app that somehow hosts the following elements. For readability, layout properties have been removed.
```





```

Create a button or similar logic that moves the content in the visual tree. Example:
```
object content = this.Parent1.Content;
this.Parent1.Content = null;
this.Parent2.Content = content;
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.