Beispiel #1
0
 /// <summary>
 /// Sets the border.
 /// </summary>
 /// <param name="view">The view.</param>
 private void SetBorder(ExtendedEntry view)
 {
     if (view.IsPassword && _thisPasswordBox != null)
     {
         _thisPasswordBox.BorderThickness = view.HasBorder ? new System.Windows.Thickness(2) : new System.Windows.Thickness(0);
         _thisPasswordBox.BorderBrush = new SolidColorBrush(Colors.Black);
     }
     else if (!view.IsPassword && _thisPhoneTextBox != null)
     {
         _thisPhoneTextBox.BorderThickness = view.HasBorder ? new System.Windows.Thickness(2) : new System.Windows.Thickness(0);
         _thisPhoneTextBox.BorderBrush = new SolidColorBrush(Colors.Black);
     }
 }
		/// <summary>
		/// Sets the text alignment.
		/// </summary>
		/// <param name="view">The view.</param>
		private void SetTextAlignment(ExtendedEntry view)
		{
			switch (view.XAlign)
			{
			case TextAlignment.Center:
				Control.TextAlignment = UITextAlignment.Center;
				break;
			case TextAlignment.End:
				Control.TextAlignment = UITextAlignment.Right;
				break;
			case TextAlignment.Start:
				Control.TextAlignment = UITextAlignment.Left;
				break;
			}
		}
Beispiel #3
0
 /// <summary>
 /// Sets the MaxLength Characters.
 /// </summary>
 /// <param name="view">The view.</param>
 private void SetMaxLength(ExtendedEntry view)
 {
     if (_thisPhoneTextBox != null) _thisPhoneTextBox.MaxLength = view.MaxLength;
 }
Beispiel #4
0
        /// <summary>
        /// Sets the font.
        /// </summary>
        /// <param name="view">The view.</param>
        /// <summary>
        /// Sets the color of the placeholder text.
        /// </summary>
        /// <param name="view">The view.</param>
        private void SetPlaceholderTextColor(ExtendedEntry view)
        {
            //the EntryRenderer renders two child controls. A PhoneTextBox or PasswordBox
            // depending on the IsPassword property of the Xamarin form control

            if (view.IsPassword)
            {
                //NotCurrentlySupported: Placeholder text color is not supported on Windows Phone Password control
            }
            else
            {
                //if (view.PlaceholderTextColor != Color.Default && _thisPhoneTextBox != null)
                //{
                //    var hintStyle = new System.Windows.Style(typeof(System.Windows.Controls.ContentControl));
                //    hintStyle.Setters.Add(
                //        new System.Windows.Setter(
                //            System.Windows.Controls.Control.ForegroundProperty,
                //            view.PlaceholderTextColor.ToBrush())
                //        );
                //    _thisPhoneTextBox.HintStyle = hintStyle;
                //}
            }
        }
Beispiel #5
0
        /// <summary>
        /// Sets the text alignment.
        /// </summary>
        /// <param name="view">The view.</param>
        private void SetTextAlignment(ExtendedEntry view)
        {
            if (view.IsPassword && _thisPasswordBox != null)
            {
#pragma warning disable CS1522 // Empty switch block
                switch (view.XAlign)
                {
                    //NotCurrentlySupported: Text alaignement not available on Windows Phone for Password Entry
                }
#pragma warning restore CS1522 // Empty switch block
            }
            else if (!view.IsPassword && _thisPhoneTextBox != null)
            {
                switch (view.XAlign)
                {
                    case TextAlignment.Center:
                        _thisPhoneTextBox.TextAlignment = System.Windows.TextAlignment.Center;
                        break;
                    case TextAlignment.End:
                        _thisPhoneTextBox.TextAlignment = System.Windows.TextAlignment.Right;
                        break;
                    case TextAlignment.Start:
                        _thisPhoneTextBox.TextAlignment = System.Windows.TextAlignment.Left;
                        break;
                }
            }
        }
		/// <summary>
		/// Sets the color of the placeholder text.
		/// </summary>
		/// <param name="view">The view.</param>
		void SetPlaceholderTextColor(ExtendedEntry view)
		{
			/*
UIColor *color = [UIColor lightTextColor];
YOURTEXTFIELD.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"PlaceHolder Text" attributes:@{NSForegroundColorAttributeName: color}];
            */
			if(string.IsNullOrEmpty(view.Placeholder) == false && view.PlaceholderTextColor != Color.Default) {
				NSAttributedString placeholderString = new NSAttributedString(view.Placeholder, new UIStringAttributes(){ ForegroundColor = view.PlaceholderTextColor.ToUIColor() });
				Control.AttributedPlaceholder = placeholderString;
			}
		}
		/// <summary>
		/// Sets the maxLength.
		/// </summary>
		/// <param name="view">The view.</param>
		private void SetMaxLength(ExtendedEntry view)
		{
			Control.ShouldChangeCharacters = (textField, range, replacementString) =>
			{
				var newLength = textField.Text.Length + replacementString.Length - range.Length;
				return newLength <= view.MaxLength;
			};
		}
		/// <summary>
		/// Sets the border.
		/// </summary>
		/// <param name="view">The view.</param>
		private void SetBorder(ExtendedEntry view)
		{
			Control.BorderStyle = view.HasBorder ? UITextBorderStyle.RoundedRect : UITextBorderStyle.None;
		}
		/// <summary>
		/// Sets the font.
		/// </summary>
		/// <param name="view">The view.</param>
		private void SetFont(ExtendedEntry view)
		{
			UIFont uiFont;
			if (view.Font != Font.Default && (uiFont = view.Font.ToUIFont()) != null)
				Control.Font = uiFont;
			else if (view.Font == Font.Default)
				Control.Font = UIFont.SystemFontOfSize(17f);
		}