Add tooltop for ToggleButton : ToggleButton « Windows Presentation Foundation « C# / CSharp Tutorial






using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Input;
using System.Windows.Media;

    public class MainClass : Window
    {
        [STAThread]
        public static void Main()
        {
            Application app = new Application();
            app.Run(new MainClass());
        }
        public MainClass()
        {
            ToggleButton btn = new ToggleButton();
            btn.Content = "press me";
            btn.HorizontalAlignment = HorizontalAlignment.Center;
            btn.VerticalAlignment = VerticalAlignment.Center;
            btn.SetBinding(ToggleButton.IsCheckedProperty, "Topmost");
            btn.DataContext = this;
            Content = btn;

            ToolTip tip = new ToolTip();
            tip.Content = "text content";
            btn.ToolTip = tip;
        }
    }








24.6.ToggleButton
24.6.1.Create ToggleButton and set string as content, set HorizontalAlignment and VerticalAlignment for ToggleButton
24.6.2.Set data binding for ToggleButton, Set DataContext for ToggleButton
24.6.3.Add tooltop for ToggleButton
24.6.4.ToggleButton check/uncheck event