I have a style setup in my XAML for the creation of round corner Buttons in my WPF window. I would like this style to apply to all buttons on all windows in my
If you want to do it in a clean way, you can create a ResourceDictionary.xaml, that has the same funcion that CSS in Web design.
First, go to your project and add a ResourceDictionary. Inside it you can add styles for all the desired elements you want, for example, change color background of a Button that applies to all your buttons:
// Base style for all buttons
If you don't specify an identifier on each Style, that style will apply to all controls that match with the
TargetType you specified. If you want button to look different, you can do the same as above, but also include an identifier to that style, that will be used by each different button:
// Specific style for blue buttons
Then, on each .xaml that you want styles to be applied you have to add the reference to this ResourceDictionary.xaml that you are creating:
I think this is what you are looking for.
If you want to draw a rounded button, you need to override the Template property of the button. This means that you need to tell button every action he needs to do from the moment you override it. See here. So, in a little and reduced concept, you would like to write something like this:
See that here I override all basic properties needed to draw a basic funcitonal button, like Foreground, Background, Width... and the MouseOver event, to change colour when passing mouse over it. The CornerRadius property of the Border inside ControlTemplate is the radius you are looking for.
So basically, you are overriding the border property that comes by default for all buttons.