Telerik blogs
OpenSource_870x220

When Microsoft announced it would be making WinForms and WPF open source, our Telerik team jumped at the opportunity to be among the first contributors.

Microsoft recently announced WinForms and WPF are now open source. It is a natural progression of the company’s open source efforts and further delivers on its promise to the developer community.

Working alongside Microsoft, our team - led by Stefan Stefanov - submitted one of the first pull requests to be merged in the WinForms repo on GitHub: support for PlaceholderText in the TextBox control.

The concept behind the feature is simple - it has a single property called PlaceholderText. When set, the control allows developers to show a watermark with a description if the text of a control is set to null.

Prior to this feature being merged, in order to provide guidance for the users as to what input is expected in a text field, the only option was to have a label next to the TextBox control. However, there are cases where labels are not appropriate, and it is much more user friendly to have a placeholder text in the TextBox itself to provide users with prescriptive guidance for input expectations. A prime use case for this would be the user name and password fields.

How it Works

A single public property called PlaceholderText is introduced, with no default value. When the property is set AND the TextBox.Text is null or string.Empty, the string from the PlaceholderText will be drawn in the TextBox control when it has no focus, using the SystemColors.GrayText.

Once the property value is changed the new text will be drawn, if currently visible. When the user focuses on the control, the text disappears. Different text alignments and RightToLeft are taken into consideration when the PlaceholderText is being drawn. It supports Multiline mode as well.

In addition, AccessibilityObject has been implemented to return the PlaceholderText when the Text is empty, so screen readers read the PlaceholderText value and guide the users as to what is expected from them as input.

On the bottom left side of the image you can see a TextBox with PlaceholderText drawn.

PlaceholderText

We are excited about the future of desktop development with WinForms and WPF and were thrilled to be a part of the group of developers making Microsoft’s desktop libraries even stronger. What’s more, with the frameworks now open source, we can access the code at a deeper level and address issues in a self-serve model. This will enable us to deliver better products faster to you and address issues that in the past may have required more detailed and lengthy interactions with Microsoft. If you don't have a license of Telerik UI for WinForms or Telerik UI for WPF, make sure you download a trial.

What are your thoughts on WinForms and WPF being open sourced? Is it a good thing for you as a desktop developer? What do you hope to see from the frameworks in the future and do you plan to contribute? Share your thoughts with us.


Sara Faatz
About the Author

Sara Faatz

Sara Faatz leads the Telerik and Kendo UI developer relations team at Progress. She has spent the majority of her career in the developer space building community, producing events, creating marketing programs, and more. When she's not working, she likes diving with sharks, running, and watching hockey.

Related Posts

Comments

Comments are disabled in preview mode.