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

Please add Command implementation sample for creating own Control Librarys with Templated Control Template-File #19156

Open
DevTKSS opened this issue Jan 5, 2025 · 2 comments
Labels
difficulty/starter 🚀 Categorizes an issue for which the difficulty level is reachable by newcomers kind/documentation project/documentation 📖 Categorizes an issue or PR as relevant to documentation

Comments

@DevTKSS
Copy link
Contributor

DevTKSS commented Jan 5, 2025

What would you like clarification on

Current Page: https://github.com/unoplatform/uno/blob/master/doc/articles/guides/how-to-create-control-libraries.md/#L1

The current Example is only including Text setting and I would like to create a own Control that would also contain a Button/AppBarButton, which should be bindable also, but when I am trying to implement the CanExcecute of the DependencyProperty Command typed to ICommand, it wants me to initialize this Command in the constructor, to be able to listen to changes. Maybe that would be done with a eventhandler correctly (looked up the AppBarButton Definition where a private readonly SerialDisposable is used...
I would "simply" like to set the IsEnabled Property from that Button from the CanExecute...

Thats why I would like clarification on this.

Concern

Developing with Uno

Affected platforms

WebAssembly, Android, iOS, Mac Catalyst, Skia (WPF), Skia (Linux X11), Skia (macOS), Skia (Linux Framebuffer), Skia (GTK), Windows (WinAppSDK)

Any feedback?

Especially for those (like me) who are using mvux this topic is maybe harder to understand than for mvvm users who are creating these Commands every time they writing their ViewModel Code which is generated in mvux.

@DevTKSS DevTKSS added difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/documentation triage/untriaged Indicates an issue requires triaging or verification labels Jan 5, 2025
@MartinZikmund
Copy link
Member

@DevTKSS You should be able to create a dependency property with ICommand type and then just detach from the previous value/attach to the new value's CanExecuteChanged event to listen to when CanExecute should be called on the instance set there - and then apply the required property like IsEnabled

@MartinZikmund MartinZikmund added project/documentation 📖 Categorizes an issue or PR as relevant to documentation difficulty/medium 🤔 Categorizes an issue for which the difficulty level is reachable with a good understanding of WinUI difficulty/starter 🚀 Categorizes an issue for which the difficulty level is reachable by newcomers and removed triage/untriaged Indicates an issue requires triaging or verification difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. difficulty/medium 🤔 Categorizes an issue for which the difficulty level is reachable with a good understanding of WinUI labels Jan 6, 2025
@DevTKSS
Copy link
Contributor Author

DevTKSS commented Jan 6, 2025

Hm okay, will try this. Does that also apply to ICommand Bindings in case of viewModels? Like if I would listen to a CanExcecuteChanged of a command property there? Or would I need to detach before resetting that private Property on my View Datacontext Changed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty/starter 🚀 Categorizes an issue for which the difficulty level is reachable by newcomers kind/documentation project/documentation 📖 Categorizes an issue or PR as relevant to documentation
Projects
None yet
Development

No branches or pull requests

2 participants