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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:49:47+00:00 2026-05-25T00:49:47+00:00

My first row looks something like this: Title 1 2 3 4 5 6

  • 0

My first row looks something like this:

Title 1 2 3 4 5 6 7 ...

If I choose

ColumnWidth="Auto"

it sizes it correctly, but there is too much space between the columns. Is there a way to shrink that? I tried in the code behind my xaml where I get the data to do

if (textColumn != 0) {
textColumn.Width = 8;
}

or something along those lines, but the size doesn’t seem to change. I’m not sure if this is correct as I’m new to WPF and C#. Thanks.

Edit:

XAML:

<DataGrid x:Name="dtGridReads"  AutoGenerateColumns="False" 
        VirtualizingStackPanel.IsVirtualizing="True"                                       
        VirtualizingStackPanel.VirtualizationMode ="Standard"
          EnableColumnVirtualization="True"
          EnableRowVirtualization="True"
        ScrollViewer.IsDeferredScrollingEnabled="True"
        CanUserReorderColumns="False" CanUserResizeColumns="False" CanUserSortColumns="True"
         ItemsSource ="{Binding}" Block.TextAlignment="Center"
         AlternatingRowBackground="LightGoldenrodYellow" RowBackground="White"
          CanUserAddRows="False" CanUserDeleteRows="False" FrozenColumnCount="1"
           GridLinesVisibility="None" Style="{StaticResource ConcensusDataGridStyle}" FontSize="12" >
</DataGrid>
  • 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-25T00:49:47+00:00Added an answer on May 25, 2026 at 12:49 am

    You will need to create a column width converter class and pass in a value to the converter to set your size accordingly.

    Here is the converter

     private const double StaticGridWidth = 602;
    
    
    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        if ((value != null) && (parameter != null))
        {
            double newValue = (double)value - StaticGridWidth;
            double dparam = double.Parse(parameter.ToString());
            double width = newValue * (dparam/1000);
            return (width > 0) ? width : 0;
        }
    
        return null;
    }
    

    Here is the usage in XAML

    <Converters:WidthConverter x:Key="widthConvert" />
    
    <GridViewColumn Header="{Binding TypeColumnHeader}"  
                                    Width="{Binding Path=ActualWidth, ElementName=treeGrid, Converter={StaticResource widthConvert}, ConverterParameter=190}" 
    
                                />
    

    Note that the values you pass in must be whole numbers if you are building a regional application. If you are using decimals in xaml and the local uses , for the decimal – it will EXPLODE.

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

Sidebar

Related Questions

My data table looks something like this (first row = column names): Name; Number;
First off the html row looks like this: <tr class=evenColor> blahblah TheTextIneed blahblah and
the row source for a listbox looks like this: SELECT users.id, users.first, users.last, chavrusas.luser_type
I have a mysql table that looks something like this: Row 1: 'visitor_input_id' =>
say I want to make the first row of the excel ss something like
Have a vector of vectors that looks something like this 3 1 2 0
My input to gnuplot looks something like this: 1:00am 1 10 1:00am 30 12
I have a table that looks something like this. <table> <thead> <tr> <th>Foo</th> <th>Bar</th>
I have a general query that looks like this: SELECT DISTINCT pb.id, pb.last, pb.first,
I'm using Codeigniter's Active Record Class. So the query looks something like this: $query

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.