locked
PlaceholderText property in RichEditBox

    Question

  • Hello Everyone,

    Can anyone please help on how to set the PlaceholderText property for a RichEditBox in windows store app?  I tried setting it through XAML and for some reason when the RichEditBox gets loaded, it doesn't show the PlaceholderText.

    Also, could anyone please tell in what scenarios this PlaceholderText will disappear in RichEditBox?

    Thanks & Regards,

    Kanchana

    Wednesday, April 16, 2014 10:32 PM

Answers

  • Hi Kanchana,

    Could you share your code with us or tell us what you have done? Basically if you set the PlaceholderText to the RichEditBox without modify any template or style, it should work fine.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Thursday, April 17, 2014 2:56 AM
    Moderator

All replies

  • Hi Kanchana,

    Could you share your code with us or tell us what you have done? Basically if you set the PlaceholderText to the RichEditBox without modify any template or style, it should work fine.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Thursday, April 17, 2014 2:56 AM
    Moderator
  • Thanks James for your reply.  Looks like I have commented the

    PlaceholderTextContentPresenter in the style and it was preventing the placeholder text to be visible.  Once I uncommented it, it is working fine.  I am able to see the placeholder text.

    Could you please help me with one more question?  Basically I am looking for setting the font size of the placeholder text with the RichEditBox font size.  I tried it setting through the style with below code, but still the font size in placholder size doesn't seem to be changed with the below setting,

                           

    <ContentControlx:Name="PlaceholderTextContentPresenter"Grid.ColumnSpan="2"Content="{TemplateBindingPlaceholderText}"Foreground="{TemplateBindingForeground}"IsHitTestVisible="False"IsTabStop="False"Margin="{TemplateBindingBorderThickness}"Padding="{TemplateBindingPadding}"Grid.Row="1"FontStyle="Normal"FontStretch="Normal"FontWeight="Normal"FontFamily="{TemplateBindingFontFamily}"FontSize="{TemplateBindingFontSize}"/>

    Could you please help with the above issue?

    Thanks & Regards,

    Kanchana

    Thursday, April 17, 2014 5:58 PM
  • Hi Kanchana,

    As you can see there is a FontSize attribute in the PlaceholderTextContentPresenter, resize it. Here I directly modify the FontSize attribute as 30, a suggested way is to binding with pre-set value as "Other Resource" in RichEditBox styles and templates does.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Friday, April 18, 2014 1:31 AM
    Moderator
  • Hi James,

    Thanks for your reply.

    I tried setting FontSize property with 30 value and I see the placeholder text size being increased.  But I am facing an issue of Placeholder text size not matching with the actual text size in the text box.  For eg, if I set the actual text size in RichEditBox as 20 and Font Size property for placeholdertext in control template as 20, I see a difference the text size.  Only if I put 25 in font size property I see it is matching with the actual text font size.  Wondering if am missing anything here.  In the below snapshot below, "Add Text" is the placeholder text of font size 20 and "Add" text is the actual text in the RichEditBox of font size 20. 

    Could you please advise how to avoid this problem?

    Thanks for your help.

    Regards,

    Kanchana

    Friday, April 18, 2014 6:45 PM