You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Please add Command implementation sample for creating own Control Librarys with Templated Control Template-File #19156
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 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
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?
@Xiaoy312 just scrolling and possible closing as already solved through issues I opened on my learning path...
what would you think about this idea of mine to help those beginners with that kind of things like me getting started with this in our uno apps:
You explained to me on the toolkit Discussion thread with sample code, how I could for example create DependencyProperty's with
using that DynamicDependency Attribute, which I would not directly remember to have seen or got explained on the linked ms docs 🤔👀
how to use a DependencyProperty with ICommand & how to correctly register for existing events/maybe calling our own events if needed that could be listened to, to then enabling bind-able control definitions especially if we might be using mvux where we normally avoid Codebehind and (e.g. me) did not learn mvvm before😅🤷 the ms docs are just told me that days I readed through this linked docs, how to use that basic Property for callback 🤔
interesting also would be to get told what we might can do with the uno provided DisposableDependencyPropertyCallback and its overloads that are available in the Codebehind for example of a simple Page. What should we maybe know to better decide which of them to use and if applying, which different behaviors should we expect from it? Maybe the disposable one is better to be used in mvux looking to the updating part of mvux 🤔 I would assume it is disposing the old page when sending us the updated new one, so a disposable definition might be then the better choice 🤷
We should optimally be told in the docs, that we are not recommended to have CommunityToolkit.Mvvm + Mvux in the same project and then should instead add a Library Project, as I was told on discord from Jeromé after I had trouble with Hot Reload + trying to use mvux for my own control definition, but I never seen this limitation stated on the docs.
Learning by failing makes of course not the best experience, so we could maybe improve this a slightly bit 👍
There are so much cool things we could use in uno apps specifically that are not told about and not available if we use ms things only, that it would be helpful to get some more information and guidance for it into the docs, not only by asking on discord or here and then beeing told... Would maybe also ease the effort for the team to then just link us to there🤷
What do you think, is this a considerable enhancement that could be planned to get into the uno docs for this topic?
This issue has had no activity for 120 days. It will be closed in 10 days if there is no further activity. Remove the Stale label or leave a comment to keep it open.
Thanks for the detailed write-up @DevTKSS - this is a fair request. Adding an ICommand-typed DependencyProperty example (with CanExecuteChanged wiring via SerialDisposable, like AppBarButton does internally) to the how-to-create-control-libraries guide would meaningfully help folks building templated controls, especially MVUX users who don't get commands generated for them. Keeping this open and marking it as a good docs starter task - the issue already has kind/documentation and difficulty/starter labels, so it's well-suited for a community contribution. The broader guidance points you raised (CommunityToolkit.Mvvm + MVUX coexistence, DisposableDependencyPropertyCallback usage) are worth separate focused doc issues so each can be addressed cleanly.
This issue has had no activity for 120 days. It will be closed in 10 days if there is no further activity. Remove the Stale label or leave a comment to keep it open.
Hi! I'd like to work on this. Following Martin's suggestion above, I plan to add an ICommand-typed DependencyProperty example to the control libraries guide, showing how to wire up CanExecuteChanged with SerialDisposable the way AppBarButton does internally. Could this be assigned to me?
Activity
MartinZikmund commentedon Jan 6, 2025
@DevTKSS You should be able to create a dependency property with
ICommandtype and then just detach from the previous value/attach to the new value'sCanExecuteChangedevent to listen to whenCanExecuteshould be called on the instance set there - and then apply the required property likeIsEnabledDevTKSS commentedon 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?
DevTKSS commentedon Oct 3, 2025
@Xiaoy312 just scrolling and possible closing as already solved through issues I opened on my learning path...
what would you think about this idea of mine to help those beginners with that kind of things like me getting started with this in our uno apps:
You explained to me on the toolkit Discussion thread with sample code, how I could for example create DependencyProperty's with
using that
DynamicDependencyAttribute, which I would not directly remember to have seen or got explained on the linked ms docs 🤔👀how to use a DependencyProperty with ICommand & how to correctly register for existing events/maybe calling our own events if needed that could be listened to, to then enabling bind-able control definitions especially if we might be using mvux where we normally avoid Codebehind and (e.g. me) did not learn mvvm before😅🤷 the ms docs are just told me that days I readed through this linked docs, how to use that basic Property for callback 🤔
interesting also would be to get told what we might can do with the uno provided
DisposableDependencyPropertyCallbackand its overloads that are available in the Codebehind for example of a simple Page. What should we maybe know to better decide which of them to use and if applying, which different behaviors should we expect from it? Maybe the disposable one is better to be used in mvux looking to the updating part of mvux 🤔 I would assume it is disposing the old page when sending us the updated new one, so a disposable definition might be then the better choice 🤷We should optimally be told in the docs, that we are not recommended to have CommunityToolkit.Mvvm + Mvux in the same project and then should instead add a Library Project, as I was told on discord from Jeromé after I had trouble with Hot Reload + trying to use mvux for my own control definition, but I never seen this limitation stated on the docs.
Learning by failing makes of course not the best experience, so we could maybe improve this a slightly bit 👍
There are so much cool things we could use in uno apps specifically that are not told about and not available if we use ms things only, that it would be helpful to get some more information and guidance for it into the docs, not only by asking on discord or here and then beeing told... Would maybe also ease the effort for the team to then just link us to there🤷
What do you think, is this a considerable enhancement that could be planned to get into the uno docs for this topic?
github-actions commentedon May 10, 2026
This issue has had no activity for 120 days. It will be closed in 10 days if there is no further activity. Remove the Stale label or leave a comment to keep it open.
MartinZikmund commentedon May 18, 2026
Thanks for the detailed write-up @DevTKSS - this is a fair request. Adding an
ICommand-typedDependencyPropertyexample (withCanExecuteChangedwiring viaSerialDisposable, likeAppBarButtondoes internally) to the how-to-create-control-libraries guide would meaningfully help folks building templated controls, especially MVUX users who don't get commands generated for them. Keeping this open and marking it as a good docs starter task - the issue already haskind/documentationanddifficulty/starterlabels, so it's well-suited for a community contribution. The broader guidance points you raised (CommunityToolkit.Mvvm + MVUX coexistence,DisposableDependencyPropertyCallbackusage) are worth separate focused doc issues so each can be addressed cleanly.github-actions commentedon Sep 16, 2026
This issue has had no activity for 120 days. It will be closed in 10 days if there is no further activity. Remove the Stale label or leave a comment to keep it open.
adarsh6980 commentedon Sep 24, 2026
Hi! I'd like to work on this. Following Martin's suggestion above, I plan to add an ICommand-typed DependencyProperty example to the control libraries guide, showing how to wire up CanExecuteChanged with SerialDisposable the way AppBarButton does internally. Could this be assigned to me?