WPF气泡提示框的简单制作
程序员文章站
2022-03-14 08:08:54
本文实例为大家分享了wpf气泡提示框的具体代码,供大家参考,具体内容如下
直接上代码
本文实例为大家分享了wpf气泡提示框的具体代码,供大家参考,具体内容如下
直接上代码
<textbox name="account" gotfocus="account_gotfocus" lostfocus="account_lostfocus" style="{staticresource labeltextbox}" xl:controlattachproperty.label="用户名:" foreground="black" margin="10,10,273,271" width="auto" />
先在前台创建一个textbox,然后各种附加的属性加上去:如图所示
<popup name="pop3" allowstransparency="true" staysopen="true" popupanimation="fade" isopen="false" placementtarget="{binding elementname=account}" placement="right" > <label style="{staticresource tiplable}"> <stackpanel orientation="horizontal"> <label content="请输入用户名"/> </stackpanel> </label> </popup>
效果图:
样式代码:
<style targettype="label" x:key="tiplable"> <setter property="template"> <setter.value> <controltemplate targettype="{x:type label}"> <grid> <border cornerradius="4" borderbrush="black" borderthickness="1" verticalalignment="top" margin="8.5,0,0,0" background="yellow" horizontalalignment="left" padding="5"> <contentpresenter /> </border> <canvas width="10" height="10" horizontalalignment="left" verticalalignment="top" margin="0,10,0,0" background="transparent"> <path stroke="black" strokethickness="0.5" fill="yellow"> <path.data> <pathgeometry figures="m 10,0 l 10,0,0,5 l 0,5,10,10"/> </path.data> </path> </canvas> </grid> </controltemplate> </setter.value> </setter> </style>
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。