c# - Changing an icon style for a toggle button in xaml -
i trying change icon used toggle button depending on state ischecked is, examples can find of how use image display icon.
i however, have static icon styles rather images wondering how can this.
as starting point if create toggle botton this:
<togglebutton style="{staticresource togglebuttonstyle}"> <path style="{staticresource test1iconstyle}" horizontalalignment="right" /> </togglebutton>
then displays togglebutton style , correct icon.
so lets click button, need reset 'path' 'test2iconstyle' based on ischecked value.
is possible?
instead of toggling style, suggest have 2 separate paths in resources , based on condition can toggle them this:
<stackpanel> <stackpanel.resources> <path x:key="test1"/> <path x:key="test2"/> </stackpanel.resources> <togglebutton> <togglebutton.style> <style targettype="togglebutton" basedon="{staticresource togglebuttonstyle}"> <setter property="content" value="{staticresource test1}"/> <style.triggers> <trigger property="ischecked" value="true"> <setter property="content" value="{staticresource test2}"/> </trigger> </style.triggers> </style> </togglebutton.style> </togglebutton> </stackpanel>
Comments
Post a Comment