Bug 35355 - Textalignment.Center not working for Entry.Placeholder
Summary: Textalignment.Center not working for Entry.Placeholder
Status: RESOLVED FEATURE
Alias: None
Product: Forms
Classification: Xamarin
Component: Windows ()
Version: 1.5.1
Hardware: PC Windows
: Normal normal
Target Milestone: UWP
Assignee: E.Z. Hart [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2015-10-29 10:10 UTC by R.Schindler
Modified: 2016-02-03 20:01 UTC (History)
2 users (show)

Tags: ac Windows
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FEATURE

Description R.Schindler 2015-10-29 10:10:24 UTC
When I create this CustomRenderer for Entry the TextAlignment doesn't get applied to the Placeholder property.

using Xamarin.Forms;

namespace SpaStaSchuUWP.CustomControls
{
    public class GridEntry : Entry
    {
    }
}

using Windows.UI.Xaml.Controls;
using SpaStaSchuUWP.CustomControls;
using SpaStaSchuUWP.UniWin;
using Xamarin.Forms;
using Xamarin.Forms.Platform.WinRT;
using TextAlignment = Windows.UI.Xaml.TextAlignment;

[assembly: ExportRenderer(typeof(GridEntry), typeof(GridEntryRenderer))]

namespace SpaStaSchuUWP.UniWin
{
    public class GridEntryRenderer : EntryRenderer
    {
        protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
        {
            base.OnElementChanged(e);

            if (Control != null)
            {
                var textbox = (FormsTextBox) this.Children[0];
                var textBoxContent = (Windows.UI.Xaml.Controls.Grid)textbox.Content;
                var text = (TextBox)textBoxContent.Children[1];
                text.TextAlignment = TextAlignment.Center;
            }
        }
    }
}
Comment 1 E.Z. Hart [MSFT] 2015-10-30 12:26:33 UTC
Thank you for taking the time to submit the bug. We need a little more information on the issue you're having - which Windows platform are you targeting with this custom renderer?

Warm regards,
Xamarin Forms Team
Comment 2 E.Z. Hart [MSFT] 2015-10-30 13:57:15 UTC
Disregard that last comment, I see from the forums that you're using the UWP Preview.
Comment 3 E.Z. Hart [MSFT] 2015-12-11 20:40:24 UTC
As of XF 2.0, the Entry control supports alignment of the Placeholder natively (no custom renderer required). 

You can now do something like this:

var entry = new Entry { Placeholder = "This should be centered", HorizontalTextAlignment = TextAlignment.Center };

And your placeholder text will be centered.
Comment 4 Sanjay 2016-01-31 13:12:26 UTC
E.Z. Hart

This is not work for me. i am used xamarin studio 5
Comment 5 E.Z. Hart [MSFT] 2016-02-03 20:01:48 UTC
(In reply to Sanjay from comment #4)
> E.Z. Hart
> 
> This is not work for me. i am used xamarin studio 5

Sanjay,
Could you open a separate bug for your issue and provide a repro project?

Thank you,
Xamarin Forms Team