Is there way to get name of property in XAML?
I found there is no support for nameof in XAML.
Something serving like this:
<i:InvokeCommandAction
Command="{Binding
Source={StaticResource SomeViewModel},
Path=SomeICommandImplementation}"
CommandParameter={Binding
Source={StaticResource SomeViewModel},
Path=SomeProperty,
GetNameOf=True}" />
Is there way to get string name of property in XAML.
No, there isn't. XAML is a markup language and it has no nameof
operator defined.
What you could do is to try to implement your own custom InvokeCommandAction
.
Create a class that derives from System.Windows.Interactivity.TriggerAction<DependencyObject>
, add the properties of InvokeCommandAction
(it is sealed
so you cannot derive from it) and another GetNameOf
property to it and then override the Invoke
method to use the nameof
operator.