高仿Windows Phone QQ登录界面实例代码

前端技术 2023/09/06 .NET

给 TextBox文本框前添加图片

扩展PhoneTextBox:添加一个类“ExtentPhoneTextBox”继承 PhoneTextBox ,在“ExtentPhoneTextBox”类中添加属性项:

复制代码 代码如下:

public class ExtentPhoneTextBox : PhoneTextBox
    {
        /// <summary>
        /// 文本框图片属性
        /// </summary>
        public static readonly DependencyProperty TextHeadImageProperty =
            DependencyProperty.Register(\"TextHeadImage\", typeof(ImageSource), typeof(ExtentPhoneTextBox), new PropertyMetadata(null)
            );

        /// <summary>
        /// 文本框头图片
        /// </summary>
        public ImageSource TextHeadImage
        {
            get { return base.GetValue(TextHeadImageProperty) as ImageSource; }
            set { base.SetValue(TextHeadImageProperty, value); }
        }

        /// <summary>
        /// 文本图片宽度
        /// </summary>
        public double TextHeadImageWidth
        {
            get { return (double)GetValue(TextHeadImageWidthProperty); }
            set { SetValue(TextHeadImageWidthProperty, value); }
        }

        // Using a DependencyProperty as the backing store for TextHeadImageWidth.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty TextHeadImageWidthProperty =
            DependencyProperty.Register(\"TextHeadImageWidth\", typeof(double), typeof(ExtentPhoneTextBox), new PropertyMetadata(null));

        /// <summary>
        /// 文本图片高度
        /// </summary>
        public double TextHeadImageHeight
        {
            get { return (double)GetValue(TextHeadImageHeightProperty); }
            set { SetValue(TextHeadImageHeightProperty, value); }
        }

        // Using a DependencyProperty as the backing store for TextHeadImageHeight.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty TextHeadImageHeightProperty =
            DependencyProperty.Register(\"TextHeadImageHeight\", typeof(double), typeof(ExtentPhoneTextBox), new PropertyMetadata(null));
    }
}

本文地址:https://www.stayed.cn/item/15030

转载请注明出处。

本站部分内容来源于网络,如侵犯到您的权益,请 联系我

我的博客

人生若只如初见,何事秋风悲画扇。