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

  • SEARCH
  • Home
  • 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 8213163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:01:05+00:00 2026-06-07T11:01:05+00:00

Good day, I’m in the process of styling a CheckBox control in an WPF

  • 0

Good day,

I’m in the process of styling a CheckBox control in an WPF application. My goal is to add a padding to the left of the CheckBox ‘default’ rectangle/border.

By default the padding is only applied to the content area of the CheckBox. Margin does work on the left, but in this case the CheckBox doesn’t register the click to check the box.

Anyone got an idea? Thanks in advance!!

Edit #1, in answer to Vlad, an example which shows the difference in padding/margin:

<StackPanel Orientation="Vertical">
   <Border Width="400" Height="50" BorderBrush="Black" BorderThickness="1">
      <CheckBox Content="Normal, clickable everywhere" />
   </Border>
   <Border Width="400" Height="50" BorderBrush="Black" BorderThickness="1">
      <CheckBox Content="Content padding, clickable everywhere" Padding="5" />
   </Border>
   <Border Width="400" Height="50" BorderBrush="Black" BorderThickness="1">
      <CheckBox Content="Control margin, not clickable in area 5px around" Margin="5" />
   </Border>
</StackPanel>
  • 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-06-07T11:01:07+00:00Added an answer on June 7, 2026 at 11:01 am

    Well, it’s expected to behave this way. Margin is considered to be “outside” of the control, so the margin area is not letting the clicks through to the control. The padding area, on the contrary, is considered to be the part of control (between the control itself and its “client area” where the content is rendered), so the padding area is getting the clicks.

    It looks like you can go with just Padding="5,0,0,0". (This adds padding only on the left side.) See this picture about the WPF’s box model.


    Update: based on your comment, you need to hack the default template. The default template can be found here: http://msdn.microsoft.com/en-us/library/ms752319%28v=vs.100%29.aspx.

    You would need the following changes: include the BulletDecorator into a Grid, and set the desired margin to the BulletDecorator. This must help, as hopefully the focus will be applied to the whole Grid and not the BulletDecorator. Or, alternately, you can set the margin at the BulletDecorator.Bullet‘s Border.


    Update: Of course it’s better for maintainability not to copy the whole template definition into the actual code. It can be avoided with the following trick.

    Say you’ve decided to go for setting an additional margin at the Bullet‘s Border. You can try to override the default style for Border just within the Checkbox‘s Bullet. The following trick should do this:

    <!-- first, define a style for border -->
    <Style TargetType="Border" x:Key="MyCoolBorderWithMargin">
        <Setter Property="Margin" Value="5,0,0,0"/>
    </Style>
    
    <!-- then, define a style for BulletDecorator -->
    <!-- this style overrides the style for inner borders -->
    <Style TargetType="BulletDecorator" x:Key="MyCoolDecoratorStyle">
        <Style.Resources>
            <Style TargetType="Border"
                   BasedOn="{StaticResource MyCoolBorderWithMargin}"/>
        </Style.Resources>
    </Style>
    
    <!-- finally, override the style for CheckBox -->
    <Style TargetType="CheckBox">
        <Style.Resources>
            <Style TargetType="BulletDecorator"
                   BasedOn="{StaticResource MyCoolDecoratorStyle}"/>
        </Style.Resources>
    </Style>
    

    This should help.

    Beware that this code is a hack, using the knowledge about how the default control template for CheckBox is implemented in the current WPF version. (If you are using WPF version different from 4.0, you may need to update the code, as it’s version-specific: different versions of WPF use different control templates!)

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

Sidebar

Related Questions

Good day. I try to add event to segment control, but it always take
Good day. I'd like to ask a question. Why TextBox control Txt in this
Good day. I'm using the WebClient class in my C# application in order to
Good day all, I have written an application that i require to have a
Good day! I'm planning to upgrade WebForms application and I have two possible choices:
Good day, My app is a music playing app. I control the <audio> -Tag
Good Day, We have migrated our web application to ASP.NET 2.0 from ASP.NET 1.1.
Good day all; Firstly, either a process or pseudo code is hopefully sufficient to
Good day. I have developed an application which works successfully on my local machine
Good day. I try to add new tab with navigation controller to 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.