Exemplo n.º 1
0
        /// <summary>
        ///   Adds a <see cref="T:T:ReactNative.Views.TextInput.PlaceholderAdorner"/> to the adorner layer.
        /// </summary>
        /// <param name="adornedElement">
        ///   The adorned element.
        /// </param>
        private static void AddAdorner(Control adornedElement)
        {
            var adornerLayer = AdornerLayer.GetAdornerLayer(adornedElement);

            if (adornerLayer == null)
            {
                return;
            }

            var adorners = adornerLayer.GetAdorners(adornedElement);

            if (adorners != null)
            {
                foreach (var adorner in adorners)
                {
                    if (adorner is PlaceholderAdorner)
                    {
                        adorner.InvalidateVisual();
                        return;
                    }
                }
            }

            var textBox = adornedElement as TextBox;

            if (textBox != null)
            {
                adornerLayer.Add(new PlaceholderAdorner(textBox));
                return;
            }

            var richTextBox = adornedElement as RichTextBox;

            if (richTextBox != null)
            {
                adornerLayer.Add(new PlaceholderAdorner(richTextBox));
                return;
            }

            var passwordBox = adornedElement as PasswordBox;

            if (passwordBox != null)
            {
                adornerLayer.Add(new PlaceholderAdorner(passwordBox));
                return;
            }

            // TextBox is hidden in template. Search for it.
            TextBox templateTextBox = null;

            templateTextBox = FindTextBox(adornedElement);
            if (templateTextBox != null)
            {
                PlaceholderAdorner.SetText(templateTextBox, (string)PlaceholderAdorner.GetText(adornedElement));
            }
        }
Exemplo n.º 2
0
 public void SetPlaceholder(ReactTextBox view, string placeholder)
 {
     PlaceholderAdorner.SetText(view, placeholder);
 }
Exemplo n.º 3
0
 public void SetPlaceholder(PasswordBox view, string placeholder)
 {
     PlaceholderAdorner.SetText(view, placeholder);
 }
Exemplo n.º 4
0
        /// <summary>
        ///   Adds a <see cref="T:T:ReactNative.Views.TextInput.PlaceholderAdorner"/> to the adorner layer.
        /// </summary>
        /// <param name="adornedElement">
        ///   The adorned element.
        /// </param>
        private static void AddAdorner(Control adornedElement)
        {
            var adornerLayer = AdornerLayer.GetAdornerLayer(adornedElement);

            if (adornerLayer == null)
            {
                return;
            }

            var reactTextBoxAdornerLayer = getUIElement(adornedElement, typeof(AdornerLayer)) as AdornerLayer;

            adornerLayer = reactTextBoxAdornerLayer ?? adornerLayer;

            var adorners = adornerLayer.GetAdorners(adornedElement);

            if (adorners != null)
            {
                foreach (var adorner in adorners)
                {
                    if (adorner is PlaceholderAdorner)
                    {
                        adorner.InvalidateVisual();
                        return;
                    }
                }
            }

            var textBox = adornedElement as TextBox;

            if (textBox != null)
            {
                //Get ScrollContentPresenter for ReactTextBox
                var scrollContent = getUIElement(adornedElement, typeof(ScrollContentPresenter)) as ScrollContentPresenter;

                if (scrollContent != null)
                {
                    adornerLayer.Add(new PlaceholderAdorner(scrollContent, textBox));
                }
                else
                {
                    adornerLayer.Add(new PlaceholderAdorner(textBox, textBox));
                }

                return;
            }

            var richTextBox = adornedElement as RichTextBox;

            if (richTextBox != null)
            {
                //Get ScrollContentPresenter for ReactTextBox
                var scrollContent = getUIElement(adornedElement, typeof(ScrollContentPresenter)) as ScrollContentPresenter;
                if (scrollContent != null)
                {
                    adornerLayer.Add(new PlaceholderAdorner(scrollContent, richTextBox));
                }
                else
                {
                    adornerLayer.Add(new PlaceholderAdorner(richTextBox, richTextBox));
                }
                return;
            }

            var passwordBox = adornedElement as PasswordBox;

            if (passwordBox != null)
            {
                var scrollContent = getUIElement(adornedElement, typeof(ScrollContentPresenter)) as ScrollContentPresenter;

                if (scrollContent != null)
                {
                    adornerLayer.Add(new PlaceholderAdorner(scrollContent, passwordBox));
                }
                else
                {
                    adornerLayer.Add(new PlaceholderAdorner(passwordBox, passwordBox));
                }
                return;
            }

            // TextBox is hidden in template. Search for it.
            TextBox templateTextBox = null;

            templateTextBox = FindTextBox(adornedElement);
            if (templateTextBox != null)
            {
                PlaceholderAdorner.SetText(templateTextBox, (string)PlaceholderAdorner.GetText(adornedElement));
            }
        }