Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4593250
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T22:39:25+00:00 2026-05-21T22:39:25+00:00

I’ve set some default styles for basic elements in WPF that act as default

  • 0

I’ve set some default styles for basic elements in WPF that act as default styles for the application, this allows controls such as buttons to all carry a similar look and feel without having to adjust manually when defined, this also means that it only needs to be changed once.

A snippet of my resource dictionary looks as follows:

<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <Style TargetType="Button">
        <Setter Property="Margin" Value="4"/>
        <Setter Property="MinWidth" Value="75"/>
        <Setter Property="Padding" Value="10,2"/>
    </Style>

</ResourceDictionary>

Notice here that I’m setting Margin to 4 for all sides. This is great as it provides a gap between buttons without the interface needing to explicitly define it. I want to know how I can for a single button, remove the gap on one side without needing to define “4” for the other sides to allow it to butt up against the side of its parent.

I don’t want to do the following as it deviates from the style (i.e. if I change 4 to 5 in my style I also need to do it here):

<DockPanel>
    <Button DockPanel.Dock="Left" Content="My Button" Margin="0,4,4,4" />
</DockPanel>

I just want to set MarginLeft somehow and leave the others as the default style I defined.

NOTE: I do have a workaround which is to simply use a named style of “buttonLeft” which is defined in the resource dictionary with no left margin.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T22:39:25+00:00Added an answer on May 21, 2026 at 10:39 pm

    i think your workaround is fine 🙂 if you want a MarginLeft Property you should create your own button and add this Property.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have some data like this: 1 2 3 4 5 9 2 6
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I want use html5's new tag to play a wav file (currently only supported
In order to apply a triggered animation to all ToolTip s in my app,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.