As you can see in that screenshot in "objArgs" there is a property "Text". How can I reach that property?
You need to cast the args to ToolBarItemEventArgs
, at which point you can access the ToolBarButton
it refers to:
var toolBarArgs = (ToolBarItemEventArgs) objArgs;
switch (toolBarArgs.ToolBarButton.Text)
{
...
}
However, I would suggest not switching on the text. Instead, ideally set up a different event handler for each of your buttons. If you really can't do that, you can use:
var toolBarArgs = (ToolBarItemEventArgs) objArgs;
var button = toolBarArgs.ToolBarButton;
if (button == saveButton)
{
...
}
Or you could switch on the Name
rather than the Text
- I'd expect the Name
to be basically an implementation detail, whereas the Text
is user-facing and could well be localized.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With