In this figure we will see that when we click on the other TextBox this will also hide its text but the watermark effect also appears again in the first TextBox. In this figure we will see that whenever we will click on the first textbox then we see that the text was written inside the hidden TextBox. In this figure we will see the default run of the application. Step 11: Now in this step we are going to run the application by pressing F5. Step 10: In this step we are going to take the look on the design of the MainPage.xaml file Step 9: In this step we will see the MainPage.xaml WatermarkedTextBox textBox = new WatermarkedTextBox() Private void Button_Click( object sender, RoutedEventArgs e) Public partial class MainPage : PhoneApplicationPage Step 8: In this step you will see that if we want to create the watermark TextBox using the button click then you can easily do that have a look at the code given below: Step 7: In this step you will see how it will appear inside your toolbox item see the figure given below: Step 6: In this step we will see how the project will be added whenever we add the existing project see the figure given below. Select the name of the library project you made.Step 5: In this step you have to add the whole library to the Windows Phone application for adding the project you have to see the images given below. Step 4: After taking the new project let you have to add the reference of the dll file which was created during build of the Windows Phone library let us see from where you have to add that library reference and also add the project see the figure given below. Step 3 : In this step you have to take a Windows Phone application to use the watermark TextBox control see the figure given below. Private void DetermineWatermarkContentVisibility() WatermarkTextBox.DetermineWatermarkContentVisibility() If(watermarkTextBox != null & watermarkTextBox.WatermarkContent != null) WatermarkedTextBox watermarkTextBox = sender as WatermarkedTextBox Private static void OnWatermarkPropert圜hanged( DependencyObject sender, DependencyPropert圜hangedEventArgs args) Protected override void OnLostFocus( RoutedEventArgs e) If (WatermarkContent != null & string.IsNullOrEmpty( this.Text)) Protected override void OnGotFocus( RoutedEventArgs e) This.WatermarkContent = this.GetTemplateChild( "watermarkContent") as ContentControl Get ĭefaultStyleKey = typeof( WatermarkedTextBox) Public static readonly DependencyProperty WatermarkStyleProperty =ĭependencyProperty.Register( "WatermarkStyle", typeof( Style), typeof( WatermarkedTextBox), null) Public static readonly DependencyProperty WatermarkProperty =ĭependencyProperty.Register( "Watermark", typeof( object), typeof( WatermarkedTextBox), new PropertyMetadata(OnWatermarkPropert圜hanged)) Public class WatermarkedTextBox : TextBox Step 2: In this step we have to write the code for the WatermarkTextBox.cs file which will be the name of the class library. Select the template Silverlight for Windows Phone->Windows Phone Class library.Step 1: In this step we have to take the Windows Phone class library. So this is the useful effect for building any page and if we have many entries through TextBox then to identify that which TextBox is used for what thing then we can identify it easily so let's we have to see the steps which is given below to implement such type of functionality. So the information to use a watermark effect is that it tells you for which thing the TextBox control is used and what you have to do to write inside the TextBox. If we don't write inside the TextBox control then it again shows the watermark effect as well. Further as you know about the watermark effect which means that whenever we will click on the TextBox control and it will be hidden so that we can write the text inside the TextBox control. In this article we are going to create a watermark effect on the TextBox control from Windows Phone 7. Now it's time to create some special effects in Windows Phone 7.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |