Brian,I used the code from the query tool (publised by SLDevTem) as base for another add-in that I wrote. They have some really nice code in the projecthttp://www.arcgis.com/home/item.html?id=451259f8e47440f2b727442fe1b2f7c2My tool runs once the button is clicked (Execute function). Assume that same should be possible with behaviourExample code from QueryTool project:
public void Execute(object parameter)
{
ToolExecuting = true;
try
{
toolView = new MyToolView()
{
Margin = new Thickness(10),
MinWidth = 400,
MinHeight = 400,
HorizontalAlignment = HorizontalAlignment.Stretch
};
toolView.Unloaded += toolViewOnUnloaded;
// Updates tool DataContext with savedConfiguration.
var toolViewModel = toolView.DataContext as MyConfigurationViewModel;
if (toolViewModel == null)
{
toolViewModel = savedConfiguration != null ? new MyConfigurationViewModel(savedConfiguration) : new MyConfigurationViewModel();
toolView.DataContext = toolViewModel;
}
else if (savedConfiguration != null)
{
toolViewModel.ApplyChanges(savedConfiguration);
}
...
// Executes tool on click when there are no visible expression.
if (toolViewModel.Execute.CanExecute(null))
toolViewModel.Execute.Execute(null);
}
catch (Exception e)
{
MapApplication.Current.ShowWindow("Error", new TextBlock() { Text = e.Message });
}
}