Google WindowsPhone Store 8.1 vs WindowsPhone 8: TextBox control having "Header" and "PlaceholderText" Properties(C#-XAML) | SubramanyamRaju Xamarin & Windows App Dev Tutorials

Sunday, 4 May 2014

WindowsPhone Store 8.1 vs WindowsPhone 8: TextBox control having "Header" and "PlaceholderText" Properties(C#-XAML)

Introduction:

The TextBox control in Windows Phone 8.1 SDK supports setting Header text. You can also modify the header template to place explicit content and/or design it as per your need. This was asked by many developers to provide in the default control, as some third party libraries already provide this feature.


Building the Sample

  • Make sure you’ve downloaded and installed the Windows Phone SDK. For more information, see Get the SDK.
  • I assumes that you’re going to test your app on the Windows Phone emulator. If you want to test your app on a phone, you have to take some additional steps. For more info, see Register your Windows Phone device for development.
  • This post assumes you’re using Microsoft Visual Studio Express 2013 for Windows.

Description:

Windows Phone 8.1 TextBox is also supports “PlaceholderText”, that means, you can now set Watermarked Text in your TextBox control. This was also part of some third party library vendors but was somehow missing in Windows Phone SDK. As these are now available directly in your default control, you can now use this without any additional cost or design efforts.
Here is the code snippet for you to try out the additional features part of Windows Phone 8.1 SDK:
XAML
 <StackPanel Margin="10">
    <TextBox Header="Header"/>
    <TextBox Header="Custom Header">
        <TextBox.HeaderTemplate>
            <DataTemplate>
                <TextBlock Text="{Binding}" FontSize="18" Foreground="Yellow"/>
            </DataTemplate>
        </TextBox.HeaderTemplate>
    </TextBox>
    <TextBox Header="Spell Check Enabled" IsSpellCheckEnabled="True"/>
    <TextBox Header="Spell Check Disabled" IsSpellCheckEnabled="False"/>
    <TextBox Header="Text Prediction Enabled" IsTextPredictionEnabled="True"/>
    <TextBox Header="Text Prediction Disabled" IsTextPredictionEnabled="False"/>
    <TextBox Header="Place Holder Text" PlaceholderText="Watermarked text"/>
</StackPanel>
  
Additionally, you can also add/remove support for SpellChecker, Text Predictions etc. while using TextBox control in your apps or games. You can see below how the Spell Checker and TextPrediction works:


Output Screens:

     



  

        














































Note: WindowsPhone 8.0 TextBox control doesn't support above properties.



Note: Please share your thoughts,what you think about this post,Is this post really helpful for you?otherwise it would be very happy ,if you have any thoughts for to implement this requirement in any another way?I always welcome if you drop comments on this post and it would be impressive.


Follow me always at  

Have a nice day by  :)

2 comments:

  1. Hi Subbu,

    Is there any way we can write this header template somewhere and and use it for text boxes everywhere across the application?

    Thanks,
    Bharath

    ReplyDelete
  2. Wow! these are wonderful tips. Thanks for sharing them with us. Please visit http://goo.gl/j1CNtj

    ReplyDelete

Search Engine Submission - AddMe