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

Collumn.Width="*" throws Exception

3 Answers 46 Views
GridView
This is a migrated thread and some comments may be shown as answers.
JTango
Top achievements
Rank 1
JTango asked on 12 Nov 2008, 08:27 AM
I have a bug when I set the width of a column to * (i.e. take up all remaining space). This works fine if I populate the DataContext before I view the grid (e.g. in the constructor of WPF page) but fails when I populate the DataContext after the grid has been created and laid out (e.g. User choose an item to display in the grid at runtime).

Here is the code need to recreate the problem.

public class DummyObject 
    { 
 
        public DummyObject(string name, string notes) 
        { 
            Name = name; 
            Notes = notes; 
        } 
 
        public string Name 
        { 
            get
            set
        } 
 
        public string Notes 
        { 
            get
            set
        } 
    } 
Class or storing some data

public partial class Window1 : Window 
    { 
        public Window1() 
        { 
            InitializeComponent(); 
 
            //This works fine 
            //PopulateGrid(); 
        } 
 
        private void Populate_Click(object sender, RoutedEventArgs e) 
        { 
            //This will throw an exception 
            PopulateGrid(); 
        } 
 
        private void PopulateGrid() 
        {             
            List<DummyObject> myObjects = new List<DummyObject>() 
            { 
                new DummyObject("Justin""Here is a note"), 
                new DummyObject("Paul""Paul has a note too"), 
                new DummyObject("Sam""Sam has a note that is much longer than the other notes"), 
                new DummyObject("Dean""Nothing to see here"), 
                new DummyObject("Andrew""Blah blah blah blah"
            }; 
 
            mainGrid.DataContext = myObjects; 
        } 
    } 
Code behind of Window class

<Window x:Class="TeleirkDatagridBug.Window1" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" 
    Title="Window1" Height="300" Width="300"
    <DockPanel> 
        <StackPanel DockPanel.Dock="Top"
            <Button Content="Populate" Click="Populate_Click"/> 
        </StackPanel> 
        <telerik:RadGridView AutoGenerateColumns="False" x:Name="mainGrid" ItemsSource="{Binding}"
            <telerik:RadGridView.Columns> 
                <telerik:GridViewDataColumn Width="100" HeaderText="Name" UniqueName="Name"/> 
                <telerik:GridViewDataColumn Width="*" HeaderText="Notes" UniqueName="Notes"/> 
            </telerik:RadGridView.Columns> 
        </telerik:RadGridView> 
    </DockPanel> 
</Window> 
XAML for window

Hope you can help.

Regards

Justin

3 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 13 Nov 2008, 09:50 AM
Hi JTango,

Thank you for the detailed bug report. The info you supplied was very helpful to identify and fix the problem.
I have updated your telerik points.

The fix will appear in the next servicing release. If meanwhile the problem blocks your work please open a support ticket so I can send the fix for you.

Kind regards,
Pavel Pavlov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
JTango
Top achievements
Rank 1
answered on 23 Dec 2008, 03:59 AM
Hi Pavel,

Thankfully the latest service pack has indeed solved this problem. I am now having an issue where Wdith="*" is actually making the column in question wider than the GridView itself. This has the unfortunate side effect that it will push out any columns after it and require scrolling to bring those columns in to view. I would expect that * would make the column fill any remaining space so that everything fits nicely without the need for scroll bars.

Regards

Justin
0
Hristo Deshev
Telerik team
answered on 23 Dec 2008, 01:32 PM
Hello JTango,

We have confirmed the bug and we are working on it. I have been discussing it with Manfred in this thread, and I think I can arrange for you (and anyone affected for that matter) to get an unofficial build that has the bug fixed once we are done working on it the next couple of days.

Best wishes,
Hristo Deshev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
GridView
Asked by
JTango
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
JTango
Top achievements
Rank 1
Hristo Deshev
Telerik team
Share this question
or