开发者

Defining Textbox-behaviour in XAML without Codebehind

开发者 https://www.devze.com 2023-01-20 17:45 出处:网络
what I want to achieve is a pretty common thing, but I want to use the Silverlight advantage to keep the UI-Behaviour in XAML.

what I want to achieve is a pretty common thing, but I want to use the Silverlight advantage to keep the UI-Behaviour in XAML.

I want a Textbox which has an 'empty' state like this:

[ Name ]

(Name in gray font), and when the Textbox receives Focus, the Fontcolor 开发者_StackOverflow中文版is supposed to change to black and the Textbox is supposed to be really empty.

When Unfocused and still empty it's supposed to say "Name" in gray font again.

Now I fail to find information on how to achieve this extended behaviour without using Codebehind... and gratefully appreciate any hints ;-)


You may try to use control templates to create textbox acting your way. Check this blog entry

for an example (it's done there with checkbox). Also a good tool for creating templates is Microsoft Blend

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号