マウスがTextBlockの上にあるときにテキストの吹き出しを表示したい。
次のコードは私が得ることができる最も近いものですが、テキストを TextBox.Text 自体に挿入し、色を変更するだけです。マウスオーバー中に別のレイヤーに浮かぶ元のテキストブロックの上に、たとえば Border/StackPanel/TextBlock を配置したいと考えています。
頭字語タグを使用して、Web エクスペリエンスに似たホバー パネルを作成するにはどうすればよいですか?
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
namespace TestHover29282
{
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
TextBlock tb = new TextBlock();
tb.Text = "test";
tb.MouseEnter += new MouseEventHandler(tb_MouseEnter);
tb.MouseLeave += new MouseEventHandler(tb_MouseLeave);
MainStackPanel.Children.Add(tb);
}
void tb_MouseLeave(object sender, MouseEventArgs e)
{
TextBlock tb = sender as TextBlock;
tb.Background = new SolidColorBrush(Colors.Transparent);
tb.Text = "test";
}
void tb_MouseEnter(object sender, MouseEventArgs e)
{
TextBlock tb = sender as TextBlock;
tb.Background = new SolidColorBrush(Colors.Orange);
tb.Text += " - this should be in a popup bubble.";
}
}
}