为什么paragraph设置了ToolTip,但是把鼠标移动到段落上,ToolTip却没有显示?
--------------------编程问答-------------------- 完整的贴出来 --------------------编程问答-------------------- 前台xaml代码:
Run rr = new Run("mmmmm");
rr.Background = Brushes.Green;
rr.Foreground = Brushes.Red;
Paragraph pp = new Paragraph();
pp.ToolTip = "aaa";
pp.Inlines.Add(rr);
this.richTextBox2.Document.Blocks.Add(pp);
<Window x:Class="Test.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow">
<Grid>
<RichTextBox name="richTextBox2"></RichTextBox>
</Grid>
</Window>
后台xaml.cs代码:
[code=C#]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Test
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
Run rr = new Run("mmmmm");
rr.Background = Brushes.Green;
rr.Foreground = Brushes.Red;
Paragraph pp = new Paragraph();
pp.ToolTip = "aaa";
pp.Inlines.Add(rr);
this.richTextBox2.Document.Blocks.Add(pp);
}
}
}
[/code]
--------------------编程问答--------------------
前台xaml代码:
<Window x:Class="Test.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow">
<Grid>
<RichTextBox name="richTextBox2"></RichTextBox>
</Grid>
</Window>
后台xaml.cs代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Test
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
Run rr = new Run("mmmmm");
rr.Background = Brushes.Green;
rr.Foreground = Brushes.Red;
Paragraph pp = new Paragraph();
pp.ToolTip = "aaa";
pp.Inlines.Add(rr);
this.richTextBox2.Document.Blocks.Add(pp);
}
}
}
补充:.NET技术 , C#