How do you implement default text for a search box in WPF?

后端 未结 6 904
醉话见心
醉话见心 2021-01-05 07:09

I want to implement something exactly like \"Changing the Default Text in the Search Box\" for a WPF search TextBox. The box should show some greyed out \"Search..\" text wh

6条回答
  •  忘掉有多难
    2021-01-05 08:02

    The best way I think for these types of things is to set the background using a visual brush. The visual brush lets you paint a background using Visual Elements, combine it with a trigger based on text being empty and it's done.

    Example for Empty List Box message is here, basically the same thing. http://adammills.wordpress.com/2010/08/04/simple-empty-template-for-itemscontrols/

提交回复
热议问题