How to convert code-based WPF tooltip to Silverlight?

The following ToolTip code works in WPF .

I am trying to get it working in Silverlight .

But he gives me these errors :

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

How can I get this to work in 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);
        }
    }
}
+3
source share
1 answer

Tooltips are added to Silverlight controls using the attached property provided by ToolTipService. There is no SetInitialShowDelayand no cursor Helpfor the type in the Silverlight version Cursors.

    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);
    }
+4
source

Source: https://habr.com/ru/post/1737508/


All Articles