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

[Solved] Auto Column Widths on Bold Data

2 Answers 118 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Carl Rippon
Top achievements
Rank 1
Carl Rippon asked on 16 Nov 2010, 02:10 PM

Auto column widths appears to be a little out if the content is bold. The attached screen shot shows what I am getting (left hand side) and what I would like (right hand side). You can see that the automatic width should have been a little wider to accommodate the time.

To recreate, create a new silverlight project, copy the code below into the code behind of MainPage and run it up. You should see that the time part has been chopped off.

Is this expected behaviour? Is there a work around?

Partial Public Class MainPage
    Inherits UserControl
 
    Public Sub New()
        InitializeComponent()
 
        Dim RadGridView1 As New Telerik.Windows.Controls.RadGridView
        RadGridView1.AutoGenerateColumns = False
        RadGridView1.Columns.Add(New GridViewDataColumn With {.DataMemberBinding = New Binding("Date"), .Header = "Date", .TextWrapping = TextWrapping.Wrap})
        Dim data As New List(Of DateTime)
        data.Add(Date.Now)
        data.Add(Date.Now)
        data.Add(Date.Now)
        RadGridView1.ItemsSource = data
        AddHandler RadGridView1.RowLoaded, Sub(s, e)
                                               e.row.FontWeight = FontWeights.Bold
                                           End Sub
        LayoutRoot.Children.Add(RadGridView1)
    End Sub
 
     
End Class




2 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 17 Nov 2010, 02:16 PM
Hi Carl Rippon,

When row is loaded  the column widths are already calculated  then you set  the text to be bold  - this is the cause of the trouble.

The solution :

Instead of setting the bold font inside the RowLoaded event , use the standard Silverlight approach :

Please use Style with Setter for the font . This way you will let the framework set the font in the right moment and measurement will be correct .

Kind regards,
Pavel Pavlov
the Telerik team
See What's New in RadControls for Silverlight in Q3 2010 on Tuesday, November 16, 2010 11:00 AM - 12:00 PM EST or 10:00 PM - 11:00 PM EST: Register here>>
0
Carl Rippon
Top achievements
Rank 1
answered on 22 Nov 2010, 11:14 AM
Thanks. I eventually got this working using the RowStyleSelector property of the grid. The style selectors example in the demos was very useful.
Tags
GridView
Asked by
Carl Rippon
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Carl Rippon
Top achievements
Rank 1
Share this question
or