title: Central margin definition for a button with Materialdesigninxaml style
body: <p>I have a quick (and most likely) easy question for which I unfortunately do not find a suitable solution. My requirements are as follows:</p>
  
  <ul>
  <li>For the purpose of creating a navigation bar, I want to stack some buttons. For this purpose, I am using a stack panel.</li>
  <li>Between each of the buttons, I want to have some space. I could of course set the margin for every button, however I find this solution not very robust and instead want to define the margin centrally.</li>
  <li>What I therefore did is I defined a style within the stack panel and set the margin once. This works great with one issue: For the button I would love to use a style provided by Materialdesigninxaml. When I however set the style to the button, the margin style gets ignored.</li>
  </ul>
  
  <p>Has anyone an idea or do I need to make use of a workaround?
  Thank you guys for your help.</p>
  
  <p>Here is my sample code which works as no Materialdesigninxaml style is defined:</p>
  
  <pre><code>            &lt;StackPanel.Resources&gt;
                  &lt;Style TargetType="{x:Type Button}"&gt;
                      &lt;Setter Property="Margin" Value="0 10 0 0"/&gt;
                      &lt;Setter Property="Height" Value="50"/&gt;
                      &lt;Setter Property="Width" Value="150"/&gt;
                  &lt;/Style&gt;
              &lt;/StackPanel.Resources&gt;
              &lt;Button&gt;
                  &lt;StackPanel Orientation="Horizontal"&gt;
                      &lt;materialDesign:PackIcon Kind="Database" VerticalAlignment="Center"/&gt;
                      &lt;TextBlock Text="BUTTON 1"/&gt;
                  &lt;/StackPanel&gt;
              &lt;/Button&gt;
  </code></pre>
  
  <p>This is my code with a specified Materialdesigninxaml style which does not work:</p>
  
  <pre><code>           &lt;StackPanel.Resources&gt;
                  &lt;Style TargetType="{x:Type Button}"&gt;
                      &lt;Setter Property="Margin" Value="0 10 0 0"/&gt;
                      &lt;Setter Property="Height" Value="50"/&gt;
                      &lt;Setter Property="Width" Value="150"/&gt;
                  &lt;/Style&gt;
              &lt;/StackPanel.Resources&gt;
              &lt;Button Style="{DynamicResource MaterialDesignFlatButton}"&gt;
                  &lt;StackPanel Orientation="Horizontal"&gt;
                      &lt;materialDesign:PackIcon Kind="Database" VerticalAlignment="Center"/&gt;
                      &lt;TextBlock Text="BUTTON 1"/&gt;
                  &lt;/StackPanel&gt;
              &lt;/Button&gt;
  </code></pre>