编辑:问题的原始前提不正确,因此修改了问题:
基本上我希望一个按钮只有在鼠标悬停在包含用户控件上时才可见。这是我所拥有的简化版本:
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="MyNamespace.MyUserControl"
x:Name="myUserControl">
<Textbox>Some Text</Textbox>
<Button Visibility="{Binding ElementName=myUserControl, Path=IsMouseOver, Converter={StaticResource mouseOverVisibilityConverter}}" />
</UserControl>
如果鼠标在文本框上,但在用户控件中的其他任何地方都不起作用。