This is a migrated thread and some comments may be shown as answers.

Setting GridViewDataColumn Width to Star taking a huge space?

1 Answer 419 Views
GridView
This is a migrated thread and some comments may be shown as answers.
awt
Top achievements
Rank 1
awt asked on 12 Jul 2016, 07:41 AM

The following is a simple RadGridView code where I want to set the width of the GridViewDataColumn width property to star:

<UserControl x:Class="namespace1.UserControl1"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
             xmlns:local="clr-namespace:namespace1.View.UserControls"
             mc:Ignorable="d">

    <Grid>
        <telerik:RadGridView>
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn Width="*">
                    <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="Some text"/>
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellTemplate>
                </telerik:GridViewDataColumn>
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>
    </Grid>
</UserControl>

 

The result of this code in the attachment where the column is taking a huge space and is not shrieked until I set MaxWidth property to some value. I am not sure if this is a correct behavior. Help Please? 

1 Answer, 1 is accepted

Sort by
0
Dilyan Traykov
Telerik team
answered on 14 Jul 2016, 12:08 PM
Hello,

Setting a star-based width on a column means that it will take up all available space that is left after the other columns are measured. Since there are no other columns, in this case, the column will take up the whole width of your RadGridView unless told otherwise (by the MaxWidth property).

So, the behavior you're getting is expected and you can override it by either setting a fixed width for your RadGridView instance or by setting a MaxWidth for your column.

I hope you find this information helpful.

Regards,
Dilyan Traykov
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
GridView
Asked by
awt
Top achievements
Rank 1
Answers by
Dilyan Traykov
Telerik team
Share this question
or