Add Page HeaderTemplate by emmauss · Pull Request #20982 · AvaloniaUI/Avalonia (original) (raw)
What does the pull request do?
Adds the following api to Page
public IDataTemplate HeaderTemplate { get; set; }
This adds the ability to use a template to display a non-visual Header.
What is the current behavior?
Header currently works only if the value can be converted to a visual, that is, a text or a visual. When using a Visual for custom header designs, the visual doesn't inherit the data context of the current Page, but instead the host of the page, which is a NavigationPage in this case. Thus bindings in Header content do not work.
What is the updated/expected behavior with this PR?
With this change, Header can be set to a non-visual, such as a viewmodel, and a DataTemplate can now be used to generate the visual with proper bindings.
How was the solution implemented (if it's not obvious)?
Checklist
- Added unit tests (if possible)?
- Added XML documentation to any related classes?
- Consider submitting a PR to https://github.com/AvaloniaUI/avalonia-docs with user documentation