---
title: "How can I remove space between columns in Grid using WPF"  
description: "How can I remove space between columns in Grid using WPF"  
author: "Anonymous User"  
published: 2013-10-14  
updated: 2013-10-14  
canonical: https://www.mindstick.com/forum/1678/how-can-i-remove-space-between-columns-in-grid-using-wpf  
category: "wpf"  
tags: ["wpf"]  
reading_time: 3 minutes  

---

# How can I remove space between columns in Grid using WPF

I defined some [UserControl](https://www.mindstick.com/forum/12739/set-the-enabled-property-of-a-usercontrol-from-codebehind) for [ListBox](https://www.mindstick.com/articles/626/listbox-events-in-c-dot-net)

```
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <ListBox Height="Auto" HorizontalAlignment="Stretch" Name="deliveriesListBox" VerticalAlignment="Stretch" Width="Auto" DataContext="{Binding}" SelectionChanged="deliveriesListBox_SelectionChanged">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <Grid x:Name="LayoutRoot" xmlns:src="clr-namespace:App"  Margin="0,5">
                            <src:DItem />
                        </Grid>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        </Grid>
```

## UserControl is

```
<UserControl x:Class="App.DItem"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    d:DesignHeight="480" d:DesignWidth="480">

    <Grid x:Name="LayoutRoot" Margin="0,5">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="Auto"/>
        </Grid.ColumnDefinitions>

        <TextBlock Grid.Row="0" Grid.Column="0" FontSize="42" HorizontalAlignment="Left"  Text="Hello" VerticalAlignment="Stretch" Margin="0" />
        <TextBlock Grid.Row="1" Grid.Column="1" FontSize="20" HorizontalAlignment="Right" TextAlignment="Right" Margin="0">
                                        <Run Text="OK" />
         </TextBlock>
        <TextBlock Grid.Row="1" Grid.Column="0" FontSize="20" Text="this is working only here.." HorizontalAlignment="Left"  />
    </Grid>
</UserControl>
```

## Replies

### Reply by Anonymous User

try this one

```
 <Grid x:Name="LayoutRoot" Grid.Row="1" Margin="0,5">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <TextBlock Grid.Row="0" FontSize="42" HorizontalAlignment="Left"  Text="Hello" VerticalAlignment="Stretch" Margin="0" />

        <DockPanel Grid.Row="1">
        <TextBlock  FontSize="20" HorizontalAlignment="Right" TextAlignment="Right" Margin="0" DockPanel.Dock="Right">
                                    <Run Text="OK" />
         </TextBlock>
        <TextBlock Grid.Row="1" Grid.Column="0" FontSize="20" Text="this is working only here.." HorizontalAlignment="Left"  />
        </DockPanel>
    </Grid>
```


---

Original Source: https://www.mindstick.com/forum/1678/how-can-i-remove-space-between-columns-in-grid-using-wpf

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
