I've found out the reason behind difference in behavior. RadContextMenu is a child of RadGridView while ToolTip is in a different branch build around PopUp primite so we access columns by Ancestor source. I've write a work-around based on this code:
https://stackoverflow.com/a/1759923
public class HiddenColumnsToTooltipConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value != null && value is Camera camera)
{
try
{
var window = Application.Current.Windows.OfType<Window>().SingleOrDefault(x => x.IsActive);
var columns = ((RadGridView)FindChild(window, $"{parameter}", typeof(RadGridView))).Columns;
...
return result;
}
catch
{
}
}
return "Nothing to show";
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return Binding.DoNothing;
}
public static DependencyObject FindChild(DependencyObject reference, string childName, Type childType)
{
DependencyObject foundChild = null;
if (reference != null)
{
int childrenCount = VisualTreeHelper.GetChildrenCount(reference);
for (int i = 0; i < childrenCount; i++)
{
var child = VisualTreeHelper.GetChild(reference, i);
if (child.GetType() != childType)
{
foundChild = FindChild(child, childName, childType);
if (foundChild != null) break;
}
else if (!string.IsNullOrEmpty(childName))
{
var frameworkElement = child as FrameworkElement;
if (frameworkElement != null && frameworkElement.Name == childName)
{
foundChild = child;
break;
}
}
else
{
foundChild = child;
break;
}
}
}
return foundChild;
}