canton7 / Stylet

A very lightweight but powerful ViewModel-First MVVM framework for WPF for .NET Framework and .NET Core, inspired by Caliburn.Micro.
MIT License
994 stars 143 forks source link

Can s:Action bind to static methods? #177

Closed GF-Huang closed 3 years ago

canton7 commented 3 years ago

No, noone's ever asked for that. Is that something you need? I'm not sure how it would work...

GF-Huang commented 3 years ago

In WPF, sometimes we have a global AppCommands for global commands. Add the <AppCommands key="AppCommands" /> to the App.xaml for global use is messier. So I want to make the AppCommands methods to static.

image

canton7 commented 3 years ago

What would the syntax look like? {s:Action Thingy, Target={x:Type app:Something}}?

canton7 commented 3 years ago

We won't be able to make that work with guard proerties in this case however

GF-Huang commented 3 years ago

Maybe like {s:StaticAction xxx:AppCommands.ShowRootViewCommand}?

canton7 commented 3 years ago

That would have to be passed as a string, and I can't parse the xxx namespace from a string. I'd need to pass in a Type generated from an x:Type somewhere (I don't think x:Static can be used to refer to a method group)

GF-Huang commented 3 years ago

It seems implements, great!

canton7 commented 3 years ago

It is. I'll write up how to use it in the wiki when I get some time