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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:27:56+00:00 2026-06-17T06:27:56+00:00

I have a datagrid as given below: <DataGrid SizeChanged=dgvMap_SizeChanged Padding=0,0,0,0 VerticalAlignment=Center HorizontalAlignment=Center GridLinesVisibility=None Background=Transparent

  • 0

I have a datagrid as given below:

    <DataGrid  SizeChanged="dgvMap_SizeChanged" Padding="0,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Center" GridLinesVisibility="None" Background="Transparent" 
                                       BorderBrush="Transparent" IsReadOnly="True" ItemsSource="{Binding IsAsync=True}"  EnableColumnVirtualization="True" 
                                       EnableRowVirtualization="True" AutoGenerateColumns="True" AutoGeneratingColumn="dgvMap_AutoGeneratingColumn" 
                                       CanUserAddRows="False" CanUserSortColumns="true" CanUserDeleteRows="False" HeadersVisibility="None" 
                                       Name="dgvMap" SelectionMode="Single" Panel.ZIndex="0" Margin="0,0,0,0" VirtualizingStackPanel.VirtualizationMode="Standard" 
                                       PreviewMouseDown="dgvMap_PreviewMouseDown" >
                                <!--for removing the blue color bkground default for row selection-->
                                <DataGrid.Resources>
                                    <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent"/>
                                </DataGrid.Resources>
                                <DataGrid.CellStyle>
                                    <Style TargetType="DataGridCell">
                                        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
                                        <Setter Property="Padding" Value="0"/>
                                        <Setter Property="Height" Value="50" />
                                        <Setter Property="Width" Value="50" />
                                    </Style>
                                </DataGrid.CellStyle>
                            </DataGrid>  

This is the style of template column:

<DataTemplate x:Key="MyDataTemplate" DataType="DataRowView">
            <StackPanel Background="Transparent">
                <Image Tag="{Binding}" Name="Layer0" Margin="0,0,0,0"  Panel.ZIndex="1"  
                        ToolTipService.HasDropShadow="True" ToolTipService.ShowDuration="20000" ToolTipService.InitialShowDelay="200" >

                <Image.Resources>
                    <Style TargetType="{x:Type Image}">
                        <Setter Property="Source" Value="{Binding Converter={StaticResource IntToImageConverter}, ConverterParameter = Layer0}" />
                        <Style.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <!-- Hover image -->
                                <Setter Property="Cursor" Value="Hand"/>
                                <Setter Property="Source" Value="D:\small.png"/>

                            </Trigger>
                        </Style.Triggers>
                    </Style>
                </Image.Resources>
            </Image>
        </StackPanel>
    </DataTemplate>

Though in datagridcellstyle i have defined cell value as width and height as 50. But when i load datagrid with 9 rows its height is showing 452 instead of 450 (9*50) and in the same way width also showing more than that.
Why its showing like that??
How to avoid that??

  • 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-17T06:27:57+00:00Added an answer on June 17, 2026 at 6:27 am

    may be because there is some by default padding or margin inside the template. You can either try giving padding for cell to 0 or can see inside control template of datagrid in Expression Blend that where the space is coming from.

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

Sidebar

Related Questions

I have datagrid whichs items source is domainDataSource. How i can refresh Domain data
I have a datagrid in C#.net I have made some columns in grid editable.
I have a DataGrid with a CheckBox column. I show a popup if the
I have a DataGrid in WPF bound to an observable collection. In my UI
I have a DataGrid Shipments and Products. The shipments are always shown, and the
I have a DataGrid that represents layers - each row is an image on
I have a datagrid view which is editable. I'm getting the value of a
I have a datagrid and I want to set the value of a dropdownlist
I have a DataGrid bout to the DataView property of a typed DataTable however
I have a DataGrid in my wpf app <DataGrid Name=datagrid2 ItemSource={Binding} CanUserReorderColumns=False IsReadOnly=True SelectionMode=Single

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.