xaml - wpf custom checkbox with text inside icon -
i'm new in xaml. create custom checkbox text instead of default checkmark. kind of
[yes] accept value (checked state) [no] accept value (unchecked state)
i don't want use images "static" text. can please forward me sample or article, cover following scope.
for need modify default control template. here simple example of how might it:
<!--x:key="phonecheckbox"--> <style targettype="checkbox" x:key="yesnocheckbox"> <setter property="content" value="accept value" /> <setter property="template"> <setter.value> <controltemplate targettype="checkbox"> <grid background="transparent"> <visualstatemanager.visualstategroups> <visualstategroup x:name="commonstates"> <visualstate x:name="normal"/> <visualstate x:name="mouseover"/> <visualstate x:name="pressed" /> <visualstate x:name="disabled" /> </visualstategroup> <visualstategroup x:name="checkstates"> <visualstate x:name="checked"> <storyboard> <objectanimationusingkeyframes storyboard.targetname="checktext" storyboard.targetproperty="text"> <discreteobjectkeyframe keytime="0" value="[yes]" /> </objectanimationusingkeyframes> </storyboard> </visualstate> <visualstate x:name="unchecked" /> <visualstate x:name="indeterminate" /> </visualstategroup> </visualstatemanager.visualstategroups> <grid margin="{staticresource phonetouchtargetlargeoverhang}"> <grid.columndefinitions> <columndefinition width="32"/> <columndefinition width="*"/> </grid.columndefinitions> <border x:name="checkbackground" ishittestvisible="false" verticalalignment="center" horizontalalignment="left" background="{templatebinding background}" borderbrush="{templatebinding background}" borderthickness="{staticresource phoneborderthickness}" height="32" width="32"/> <textblock x:name="checktext" text="[no]" /> <contentcontrol x:name="contentcontainer" grid.column="1" content="{templatebinding content}" contenttemplate="{templatebinding contenttemplate}" margin="12,0,0,0" horizontalcontentalignment="{templatebinding horizontalcontentalignment}" verticalcontentalignment="{templatebinding verticalcontentalignment}" padding="{templatebinding padding}" foreground="{templatebinding foreground}" /> </grid> </grid> </controltemplate> </setter.value> </setter> </style>
i replaced check symbol textblock
toggles between "[yes]" , "[no]" (also removed "pressed", "disabled", , "indeterminate" visual state storyboards, brevity).
you can find default control templates in local sdk install.
to use above, reference style key:
<checkbox style="{staticresource yesnocheckbox}" />
Comments
Post a Comment