当前位置:编程文档 >> C# >> ToolTip的动态生成方法
首页

ToolTip的动态生成方法

所属类别:C#
推荐指数:★★☆
文档人气:11
本周人气:7
发布日期:2008-8-2
其实也就是个简单的tooltip生成,本人刚开始做wpf,不是什么高级应用


namespace UntitledProject1

{

public partial class Window1

{

public Window1()

{

this.InitializeComponent();



StackPanel sp = new StackPanel();



Label lb = new Label();

lb.FontWeight = FontWeights.Bold;

lb.Background = Brushes.Blue;

lb.Foreground = Brushes.White;

lb.Content = "检测结果";

sp.Children.Add(lb);



TextBlock tb = new TextBlock();

tb.Padding = new Thickness(10);

tb.TextWrapping = TextWrapping.WrapWithOverflow;

tb.Width = 200;

tb.Text = "都不通啊都不通";

sp.Children.Add(tb);



Line ln = new Line();

ln.Stroke = Brushes.Black;

ln.StrokeThickness = 1;

ln.X2 = 200;

sp.Children.Add(ln);



StackPanel sp2 = new StackPanel();

sp2.Orientation = Orientation.Horizontal;



//-------------------sp2中增加一张图片----------------------



Image myImage3 = new Image();

BitmapImage bi3 = new BitmapImage();

bi3.BeginInit();

bi3.UriSource = new Uri("help.jpg", UriKind.Relative);

bi3.EndInit();

myImage3.Stretch = Stretch.Fill;

myImage3.Source = bi3;

sp2.Children.Add(myImage3);



//-----------------------------------------------------------



Label lb2 = new Label();

lb2.FontWeight = FontWeights.Bold;

lb2.Content = "看什么看啊";

sp2.Children.Add(lb2);



sp.Children.Add(sp2);



ToolTip ttp = new ToolTip();



ttp.Content = sp;



button1.ToolTip = ttp;



// Insert code required on object creation below this point.

}

}

}

文档说明:

     

相关文档


读取评论列表……