2010-03-18 35 views
3

以下工具提示代码在WPF中工作。如何将此基于代码的WPF工具提示转换为Silverlight?

我试图让它在Silverlight中工作。

但它给了我这些错误

TextBlock does not contain a definition for ToolTip. 
Cursors does not contain a definition for Help. 
ToolTipService does not contain a definition for SetInitialShowDelay. 

我如何能得到这个在Silverlight中工作?

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(); 

      AddCustomer("Jim Smith"); 
      AddCustomer("Joe Jones"); 
      AddCustomer("Angie Jones"); 
      AddCustomer("Josh Smith"); 
     } 

     void AddCustomer(string name) 
     { 
      TextBlock tb = new TextBlock(); 
      tb.Text = name; 
      ToolTip tt = new ToolTip(); 
      tt.Content = "This is some info on " + name + "."; 
      tb.ToolTip = tt; 
      tt.Cursor = Cursors.Help; 
      ToolTipService.SetInitialShowDelay(tb, 0); 

      MainStackPanel.Children.Add(tb); 
     } 
    } 
} 

回答

4

工具提示被添加到使用由ToolTipService提供附加属性Silverlight控件。 Silverlight的版本中没有SetInitialShowDelayCursors类型中没有Help光标。

void AddCustomer(string name) 
    { 
     TextBlock tb = new TextBlock(); 
     tb.Text = name; 
     ToolTip tt = new ToolTip(); 
     tt.Content = "This is some info on " + name + "."; 
     ToolTipService.SetToolTip(tb, tt); 

     MainStackPanel.Children.Add(tb); 
    } 
相关问题