c# - Assign command to a set of buttons in grid through style -


is possible in silverlight assign same command set of buttons in grid through style? or assign @ common place instead of repeating?

i mean using -

<style targettype="button">    <setter property="command" value="{binding command1}"/> </style> 

instead of -

<button command="{binding command1}"/>  <button command="{binding command1}"/>  <button command="{binding command1}"/>             ... <button command="{binding command1}"/>  

it possible. in simple way can add style resources , use staticresource. assuming command1 belongs viewmodel binding window. if not, provide proper path command1 bind properly.

<window.resources>   <style x:key="buttoncommandstyle" targettype="button">     <setter property="command" value="{binding path=datacontext.command1}" />   </style> </window.resources>   

then use style button

<button style="{staticresource buttoncommandstyle}" /> 

Comments