2
ユーザーが要素の上にマウスを置いたときに表示されるポップアップを作成しようとしています。ユーザーがポップアップ上でマウスを動かすと、私はそれを表示したままにします。しかし、ユーザーがowner要素とpopup要素の両方を残すと、popup要素は消えます。Silverlight:マウスが所有者要素の上かポップアップ自体の上にあるときにポップアップを表示
私は次のことを試してみましたが、それは動作しません:背後
<UserControl x:Class="SilverlightApplication1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<StackPanel MouseEnter="OnMouseEnter" MouseMove="OnMouseMove" MouseLeave="OnMouseLeave">
<HyperlinkButton Content="Root" HorizontalAlignment="Left"/>
<Popup x:Name="popup" MouseEnter="OnMouseEnter" MouseMove="OnMouseMove" MouseLeave="OnMouseLeave">
<StackPanel x:Name="leaves" HorizontalAlignment="Left">
<HyperlinkButton Content="Leaf1" />
<HyperlinkButton Content="Leaf2" />
</StackPanel>
</Popup>
</StackPanel>
コード:
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
}
private void OnMouseMove(object sender, MouseEventArgs e)
{
this.popup.IsOpen = true;
}
private void OnMouseEnter(object sender, MouseEventArgs e)
{
this.popup.IsOpen = true;
}
private void OnMouseLeave(object sender, MouseEventArgs e)
{
this.popup.IsOpen = false;
}
}
何が起こることは、所有者要素(ルート)のMouseLeaveがトリガされているとポップアップが非表示になります。
アイデア?