I have a number of Buttons like this
<Button Content="A"
Command="{Binding ClickCommand}"
CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self},
Path=Content}" />
where the Content
property of the Button is being passed as the CommandParameter
. A single Command in the ViewModel handles all the Buttons and 'knows what to do' based on that parameter (think of a control panel / keyboard type app).
This makes for a lot of repeated XAML. How can I put this repeated code into the base style for a Button?
I believe this is not supported for Silverlight within WP7, in the same way that it was not supported in the browser-based Silverlight before SL4 (see the following workaround). You could do one of the following:
Personally, I would go for (2). This means you can still style your Buttons in the usual way.