windows - How do I make a WPF button look like a link? -
i want use buttons in wpf styled links. microsoft (seemingly inconsistently) in windows dialog boxes.
they blue text. , change color , underline when mouse cursor hovers over.
example:
i got working. (thanks christian, anderson imes, , michac) but, had put textblock
inside button.
how can improve style—to make work without requiring textblock inside button?
usage xaml
<button style="{staticresource hyperlinklikebutton}"> <textblock>edit</textblock> </button>
style xaml
<style x:key="hyperlinklikebutton" targettype="button"> <setter property="template"> <setter.value> <controltemplate targettype="button"> <contentpresenter /> </controltemplate> </setter.value> </setter> <setter property="foreground" value="{dynamicresource {x:static systemcolors.hottrackbrushkey}}" /> <setter property="cursor" value="hand" /> <style.triggers> <trigger property="ismouseover" value="true"> <setter property="foreground" value="{dynamicresource {x:static systemcolors.highlightbrushkey}}" /> <setter property="template"> <setter.value> <controltemplate targettype="button"> <controltemplate.resources> <style targettype="{x:type textblock}"> <setter property="textdecorations" value="underline" /> </style> </controltemplate.resources> <contentpresenter /> </controltemplate> </setter.value> </setter> </trigger> </style.triggers> </style>
do know there hyperlink class/tag? looks hyperlink , can work button (can use uri and/or command and/or click event).
edit:
example of usage:
<textblock> <hyperlink command="{binding somecommand, elementname=window}" commandparameter="{binding}">link </hyperlink> </textblock>
Comments
Post a Comment