Select to view content in your preferred language

Hide addon tool button instead disable it

884
0
10-01-2012 05:49 AM
ValentinFedulov
Occasional Contributor
Hello everyone.
I try to make a tool (addon) whose button in main toolbar must be hidden on some conditions. Like

public bool CanExecute(object parameter)
{
    if(noData) {myButton.Visibility = Visibility.Collapsed; return false;}
    myButton.Visibility = Visibility.Visible; return true;
}

but I can't find a way to define myButton object.
Code like
var toolbar = MapApplication.Current.FindObjectInLayout("MainToolbarContainer") as ContentControl;
int childCount = VisualTreeHelper.GetChildrenCount(toolbar);
// for each child print details ...

doesn't show any buttons.

How I can hide/show button in MainToolbar?
0 Kudos
0 Replies