国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 擴展 > SilverLight > 正文

Silverlightbutton圖片切換樣式實例代碼

2024-09-06 20:41:36
字體:
來源:轉載
供稿:網友

之前一直做WPF現在開始接觸Slilverlight感觸很多。

今天做一個Button要求

有兩個圖片,button默認有一個圖片,鼠標over時用另一個圖片,

用wpf做的時候寫一個template很簡單,但silverlight和wpf寫起來不一樣

記錄一下。大概思路是兩個image鼠標MouseOver的時候一個Visible一個Collapsed

寫的是一個自定義控件,代碼和皮膚分離,很簡單的一個demo

代碼下載:ImageButtonTest.rar

先寫一個繼承自button的imagebutton類

代碼如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace ImageButtonTest
{
    /// <summary>
    /// build by lp
    /// </summary>
    public class MyImageButton : Button
    {

        public static readonly DependencyProperty ImageNormalProperty =
            DependencyProperty.Register("ImageNormal",
                                        typeof(ImageSource),
                                        typeof(MyImageButton),
                                        new PropertyMetadata(null));

        public static readonly DependencyProperty ImageHoverProperty =
            DependencyProperty.Register("ImageHover",
                                        typeof(ImageSource),
                                        typeof(MyImageButton),
                                        new PropertyMetadata(null));

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 呼和浩特市| 玉树县| 大石桥市| 英吉沙县| 郧西县| 化德县| 崇礼县| 兰溪市| 石林| 嘉祥县| 巴彦淖尔市| 文山县| 且末县| 鄄城县| 铜梁县| 平顶山市| 武鸣县| 高州市| 莱西市| 开化县| 温州市| 繁昌县| 三都| 临泽县| 许昌县| 临海市| 江西省| 松江区| 保山市| 墨竹工卡县| 田林县| 西宁市| 长治市| 会昌县| 九龙坡区| 威信县| 澳门| 新宾| 汾阳市| 黄龙县| 霍林郭勒市|