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 6711087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:05:53+00:00 2026-05-26T08:05:53+00:00

<StackPanel Grid.Column=1 Orientation=Horizontal Margin=0,0,0,0 VerticalAlignment=Top HorizontalAlignment=Right> <StackPanel.Resources> <Style TargetType={x:Type Button}> <Setter Property=Margin Value=2,0,0,0/> </Style>

  • 0
<StackPanel Grid.Column="1" Orientation="Horizontal" Margin="0,0,0,0" VerticalAlignment="Top" HorizontalAlignment="Right">
    <StackPanel.Resources>
        <Style TargetType="{x:Type Button}">
            <Setter Property="Margin" Value="2,0,0,0"/>
        </Style>
    </StackPanel.Resources> 
    <Button Padding="5" x:Name="btnUnlock" Click="btnUserMenu_Click_1" Style="{DynamicResource ButtonStyleBasic}">
            <Image Stretch="None" Source="/WpfApplication1;component/Images/view_text.png" ImageFailed="Image_ImageFailed"/>
    </Button>
    <Button Padding="5"  Margin="2,0,0,0" x:Name="btnUserMenu" Click="btnUserMenu_Click_1" Style="{DynamicResource ButtonStyleBasic}"  >
        <Image Stretch="None" Source="/WpfApplication1;component/Images/personal.png" ImageFailed="Image_ImageFailed"/>
    </Button>
    <Button Padding="5" x:Name="btnQuit"   Margin="2,0,0,0" Click="btnQuit_Click" Style="{DynamicResource ButtonStyleBasic}">
            <Image Stretch="None" Source="/WpfApplication1;component/Images/exit.png" UseLayoutRounding="True"/>
    </Button>
    </StackPanel>

If i remove margin inside <Button ... no margin is applied.This is the case when i apply custom template.. Here is the template…

<Style x:Key="ButtonStyleBasic" TargetType="{x:Type Button}">

            <Setter Property="FocusVisualStyle" Value="{StaticResource ButtonFocusVisual}"/>
            <Setter Property="Background" Value="{StaticResource ButtonNormalBackground}"/>
            <Setter Property="BorderBrush" Value="{StaticResource ButtonNormalBorder}"/>
            <Setter Property="BorderThickness" Value="1"/>
            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
            <Setter Property="HorizontalContentAlignment" Value="Center"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <Setter Property="Padding" Value="1"/>

            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Button}">
                    <Border BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" SnapsToDevicePixels="true" CornerRadius="2" BorderThickness="{TemplateBinding BorderThickness}">
                            <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                    </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsKeyboardFocused" Value="true">

                            </Trigger>
                            <Trigger Property="ToggleButton.IsChecked" Value="true">

                            </Trigger>
                            <Trigger Property="IsEnabled" Value="false">
                                <Setter Property="Foreground" Value="#ADADAD"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
  • 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-26T08:05:54+00:00Added an answer on May 26, 2026 at 8:05 am

    The template in your style does not bind to the Margin using a TemplateBinding, hence the margin properties on Buttons with this style will be disregarded.

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

Sidebar

Related Questions

Given this XAML: <StackPanel Orientation=Horizontal Grid.Row=1 Grid.Column=0 Margin=5> How can I assign the Grid.Row
I have created a Silverlight User Control. The markup is: <StackPanel Grid.Row=4 Grid.Column=0 Orientation=Horizontal
I have horizontal wpf listview <ListView Name=indexList ItemsSource={Binding} HorizontalAlignment=Stretch VerticalAlignment=Top BorderBrush=Transparent Background=CadetBlue Width=450> <ListView.ItemsPanel>
I have this: <ListBox x:Name=PART_lstAttributes Grid.Row=1 Style={StaticResource GlossyBlackListBox}> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock x:Name=txtAttributeName Text={Binding
This is how i am binding the Autocomplete Textbox:- <sdk:AutoCompleteBox Grid.Column=1 Grid.Row=2 Height=28 HorizontalAlignment=Left
I have a vertical StackPanel with two elements: a Button and a ListBox. How
I have a horizontal StackPanel with an image and another StackPanel. The inner StackPanel
I'm using a DataGrid inside a StackPanel inside a Grid which causes the GridView
Are there in general any known performance issues in WPF related to grid column
I have a problem with displaying images in WPF. Here's my code: <Button HorizontalAlignment=Left

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.