c# - Nested Styles in WPF -


i nest styles in wpf.

i have resource dictionary:

<style x:key="bottombuttonbar" targettype="{x:type grid}">   <style targettype="{x:type button}">         <setter property="margin" value="10,2" />         <setter property="width" value="90" />     </style>      <style targettype="{x:type textblock}">         <setter property="horizontalalignment" value="center" />         <setter property="verticalalignment" value="center" />         <setter property="margin" value="2,0"/>     </style> </style> 

what want is: if apply style "bottombuttonbar" on grid, buttons inside grid have margin , width i've defined , same textblock inside grid.

how that?

i found following solution:

<style x:key="bottombuttonbar" targettype="{x:type grid}">     <style.resources>          <style targettype="{x:type button}">             <setter property="margin" value="10,2" />             <setter property="width" value="90" />         </style>          <style targettype="{x:type textblock}">             <setter property="horizontalalignment" value="center" />             <setter property="verticalalignment" value="center" />             <setter property="margin" value="2,0"/>         </style>     </style.resources> </style> 

and in xaml:

    <grid dockpanel.dock="bottom" style="{dynamicresource bottombuttonbar}"> 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -