c# - Position RadioButton XAML on center bottom of content -


i'd position wpf radio button on centered bottom of image. have stackpanel image radio button on bottom i'd clicking image triggers radio button.

when tried embed image inside radiobutton, shows on right of button. how can using static resource?

this have putting radio button on top don't know if adjusting margins way it.

        <controltemplate x:key="radiobuttonbottom" targettype="{x:type radiobutton}">             <radiobutton ischecked="{templatebinding ischecked}" margin="35 0 0 0" >                 <textblock>                 <linebreak />                 <inlineuicontainer>                     <contentpresenter margin="-50,0,0,0"                                          content="{templatebinding contentpresenter.content}"                                         contenttemplate="{templatebinding contentpresenter.contenttemplate}"/>                 </inlineuicontainer>                 </textblock>              </radiobutton>         </controltemplate> 

it should this:

wow, harder i'd expect be.. default radiobutton uses bulletdecorator internally, , don't have control of bullet's placement.

therefore, creating new controltemplate (which did) seems best option. little article: how configure wpf radiobutton's circle bullet, here suggestion:

note: need add reference presentationframework.aero in project.

<window ...         xmlns:microsoft_windows_themes="clr-namespace:microsoft.windows.themes;assembly=presentationframework.aero" >     <window.resources>         <style targettype="radiobutton" >             <setter property="template" >                 <setter.value>                     <controltemplate targettype="{x:type radiobutton}">                         <dockpanel background="transparent" >                             <microsoft_windows_themes:bulletchrome dockpanel.dock="bottom" horizontalalignment="center"                                                                    isround="true" height="{templatebinding fontsize}" width="{templatebinding fontsize}"                                                                     borderbrush="{templatebinding borderbrush}" background="{templatebinding background}"                                                                     ischecked="{templatebinding ischecked}"                                                                     rendermouseover="{templatebinding ismouseover}" renderpressed="{templatebinding ispressed}" />                             <contentpresenter recognizesaccesskey="true"                                                verticalalignment="{templatebinding verticalcontentalignment}"                                                horizontalalignment="{templatebinding horizontalcontentalignment}" />                         </dockpanel>                          <controltemplate.triggers>                             <trigger property="isenabled" value="false" >                                 <setter property="foreground" value="{dynamicresource {x:static systemcolors.graytextbrushkey}}" />                             </trigger>                         </controltemplate.triggers>                     </controltemplate>                 </setter.value>             </setter>         </style>     </window.resources>       <stackpanel orientation="horizontal" >         <radiobutton>             <image source="..." />         </radiobutton>         <radiobutton>             <image source="..." />         </radiobutton>         <radiobutton>             <image source="..." />         </radiobutton>     </stackpanel>  </window> 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -