SilverLight ImageButton
刚接触silverlight,要实现类似Asp.Net的ImageButton的按钮,
使用 Image
Image image1 = new Image();
image1.Cursor = Cursors.Hand;
string s = @"/SilverlightApplication1;component/Imgs/DSC00311.JPG";
ImageSource imageSource = new BitmapImage(new Uri(s, UriKind.RelativeOrAbsolute));
image1.Source = imageSource;
image1.MouseLeftButtonDown += new MouseButtonEventHandler(image1_MouseLeftButtonDown);
void image1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
MessageBox.Show(DateTime.Now.ToString());
}
就这样Image就有了单击事件。
补充一点:Image Source 原来不支持gif格式的图片,试了半天。