In my UI I have multiple buttons to call the OpenItemDialog and I would like to reuse the method to call the dialoge by using the CommandParameter to differentiate the initiating button.How can I do this using the RelayCommand?
This community sample shows how to do this: arcgis-pro-sdk-community-samples/Map-Exploration/TableControlsDockpane at master · Esri/arcgis-pro-sdk-community-samples (github.com)
In the xaml you can specify the CommandParameter:
<Button Command="{Binding DataContext.TableCloseCommand, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" CommandParameter="{Binding TableName}" >
TableName in this example is of the type string.
In the code behind you can use the CommandParameter by simple adding 'param' to your RelayCommand as shown here:
public ICommand TableCloseCommand { get; set; } public AttributeTableViewModel() { TableCloseCommand = new RelayCommand((param) => OnCloseTab(param), () => true); } private void OnCloseTab(object param) { // cast the [object] param to the correct type [string] string tableName = param.ToString(); // use your TableName CommandParameter for processing }
Thanks Wolf, that was precisely what I needed. 👍
Los miembros registrados pueden publicar, seguir actualizaciones y más. ¿Nuevo aquí? Regístrate gratis.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.