Search code examples
wpfdatagriddatagridcolumn

WPF datagrid column width codebehind 30*


i'd like to set the width of my datagrid column and my desired value is 30*.

I found this

 var columntu = new ExtDataGridNumericColumn()
{
    Tag = tagName,
    Header = header,
    Width = new DataGridLength(1, DataGridLengthUnitType.Auto)
};

but I can only set

public enum DataGridLengthUnitType
{
    Auto = 0,
    Pixel = 1,
    SizeToCells = 2,
    SizeToHeader = 3,
    Star = 4,
}

How can I set 30* as width of my column? Thank you Andrea


Solution

  • 30* in XAML is new DataGridLength(30, DataGridLengthUnitType.Star) in C#:

    columntu.Width = new DataGridLength(30, DataGridLengthUnitType.Star);