I am trying to bind the visibility property of the ToolTip to the IsEnabled of the Button
<Button Name="bbb" Content="Train" Command="{Binding TrainCmd}" ToolTipService.ShowOnDisabled="True">
<Button.ToolTip>
<ToolTip Content="{Binding TrainToolTip}" Visibility="{Binding IsEnabled, Converter={StaticResource InverseBooleanToVisibilityConverter}, ElementName=aaa}">
</ToolTip>
</Button.ToolTip>
</Button>
but I get the following error:
"System.Windows.Data Error: 4 : Cannot find source for binding with reference 'ElementName=aaa'. BindingExpression:Path=IsEnabled; DataItem=null; target element is 'ToolTip' (Name=''); target property is 'Visibility' (type 'Visibility')"
I also tried
<Button Content="Train" Command="{Binding TrainCmd}" ToolTipService.ShowOnDisabled="True">
<Button.ToolTip>
<ToolTip Content="{Binding TrainToolTip}" Visibility="{Binding IsEnabled, Converter={StaticResource InverseBooleanToVisibilityConverter}, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Button}}}"/>
</Button.ToolTip>
</Button>
but then I get
"System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.Button', AncestorLevel='1''. BindingExpression:Path=IsEnabled; DataItem=null; target element is 'ToolTip' (Name=''); target property is 'Visibility' (type 'Visibility') "
ToolTipService.ShowOnDisabled="True"
if you dont want to show tooltip? Why not just use<Button Content="Train" Command="{Binding TrainCmd}" ToolTip="Test"/>
directly? – Carbine