dotnet / dotnet/wpf

WPF PriorityBinding does not work if set in style and it is attached before the DataContext is available

Open
#4,306 2 comments 1 reaction 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

_This issue has been moved from [a ticket on Developer Community](https://developercommunity.visualstudio.com/t/WPF-PriorityBinding-does-not-work-if-set/1371512)._

---
[severity:It's more difficult to complete my work]
Sometimes a PriorityBinding does not retrieve value from second binding if the first becomes unavailable. Looks like it happens if the PriorityBinding is attached before the DataContext is available.

Reproduceable in both .NET Framework 4.8 and .NET 5.0.

See attached project that reproduces the issue.
[WpfApp5.zip] (https://aka.ms/dc/file?name=B1e99a947281f4a94a68736a2fca1d819637514990184193462_WpfApp5.zip&tid=1e99a947281f4a94a68736a2fca1d819637514990184193462)

1. Open WpfApp5
2. See that Current FontFamily and Default FontFamily are different. Current FontFamily is bound to both ViewModel2.FontFamily and ViewModel2.DefaultFontFamily using a PriorityBinding. If ViewModel2.FontFamily is null then DefaultFontFamily is used.
3. Click the button at the top to change ViewModel2.FontFamily to null.
4. The current FontFamily changes to Segoe UI instead of the expected Wide Latin value.

---
### Original Comments

#### Feedback Bot on 3/16/2021, 08:17 PM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

---
### Original Solutions
(no solutions)

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.