canton7 / Stylet

A very lightweight but powerful ViewModel-First MVVM framework for WPF for .NET Framework and .NET Core, inspired by Caliburn.Micro.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can s:Action bind to static methods?

GF-Huang opened this issue · comments

Can s:Action bind to static methods?

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

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

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

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

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

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)

It seems implements, great!

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