RichTextBox.Selection.GetPropertyValue(FontStyleProperty) returns DependencyProperty.UnsetValue for Hyperlink with Italic style
- Dominant language
- C#
- Stars
- 7.7k
- Forks
- 1.3k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 61
Description
* .NET Core Version: .NET 6.0.9
* Windows version: Windows 10 21H2 (19044.2006)
* Does the bug reproduce also in WPF for .NET Framework 4.8?: Yes
**Problem description:**
We use `RichTextBox.Selection.GetPropertyValue(FontStyleProperty)` to determine the selected text's style. The issue is, if the selected text is `Hyperlink` and it's fully selected, the returned style is incorrect if it's not default.
As an example for the repro below, the button's color depends on whether the selected text is `Italic` or not (blue if yes, otherwise red). By pressing the button the selected text's style is changed to/from `Italic`.
Here nothing is selected, the whole hyperlink's text is `Italic`.

Here only a part of the hyperlink is selected, the button is blue.

The whole hyperlink is selected, the button is red (even though the whole text is `Italic`).

This happens because when the whole text is selected `GetPropertyValue(FontStyleProperty)` returns `DependencyProperty.UnsetValue`.
**Actual behavior:**
`GetPropertyValue(FontStyleProperty)` returns `DependencyProperty.UnsetValue` for `Hyperlink` if has `Italic` font style.
**Expected behavior:**
`GetPropertyValue(FontStyleProperty)` should return `FontStyles.Italic` for `Hyperlink` if has `Italic` font style.
**Minimal repro:**
https://github.com/vonzshik/WpfRichTextBoxItalicLink
Contributor guide
Assessment
This issue has not been assessed yet.