Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the BindingContext property to the Window TitleBar and inherit its value from the Window's BindingContext #24831

Open
egvijayanand opened this issue Sep 19, 2024 · 3 comments

Comments

@egvijayanand
Copy link
Contributor

Description

Adding a BindingContext property to the Window TitleBar is essential, as it facilitates the binding of properties and commands of the controls hosted within it to a ViewModel instance.

Public API Changes

Add the BindingContext property to the Window TitleBar and inherit its value from the Window's BindingContext.

Intended Use-Case

To manage the properties and commands of the controls hosted within the Window TitleBar from the ViewModel.

@egvijayanand
Copy link
Contributor Author

I'm trying to bind the SearchBar, hosted in the TitleBar, to a property and command in the ViewModel.

@Foda
Copy link
Member

Foda commented Sep 19, 2024

Hello! The TitleBar in .NET 9 of MAUI supports this. You can see an example of the BindingContext (and the Window titlebar) being set here:
https://github.com/dotnet/maui/blob/net9.0/src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Windows/WindowsTileBarPage.xaml.cs#L21C1-L38C4

@egvijayanand
Copy link
Contributor Author

egvijayanand commented Sep 19, 2024

Still the BindingContext is set separately for the TitleBar. Is that the recommended approach?

I've defined the TitleBar in XAML as part of the Window definition. I'm assigning the Window BindingContext, which is not passed on to the TitleBar. The child control is supposed to inherit the parent's BindingContext.

Will upload and share the sample by tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants