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

Column width set to SizeToCells but don't resize

2 Answers 118 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jean
Top achievements
Rank 1
Jean asked on 09 May 2011, 05:29 PM
Hello,

I try to make the column width of the grid to follow the width of the bigger cell. So I've set the columnWitdh property to "SizeToCells". But it doesn't work.

I'm using the RadControls_for_Silverlight_4_2011_1_0419_Dev.

I've done a small application to show my problem : When I fill the cell witdh a large text the colunm width grow up, but when the text become smaller, the column width doesn't resize to become smaller too. 

MainPage.xaml :

<UserControl
    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" x:Name="userControl" x:Class="SilverlightApplication1.MainPage"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">
  
    <Grid x:Name="LayoutRoot" Background="White" Height="300" VerticalAlignment="Top" HorizontalAlignment="Left" Width="400">
          
        <telerik:RadGridView x:Name="grid1" 
                Margin="0,0,2,0" d:LayoutOverrides="Width" Height="157" VerticalAlignment="Top" 
                ItemsSource="{Binding Data, ElementName=userControl, Mode=TwoWay}" 
                ColumnWidth="SizeToCells"/>
  
        <Button x:Name="Button1" Content="Button Small Text" HorizontalAlignment="Left" Height="28" Margin="0,161,0,0" VerticalAlignment="Top" Width="145" Click="Button_Click"/>
        <Button x:Name="Button2" Content="Button Large Text" Height="28" Margin="149,161,115,0" VerticalAlignment="Top" RenderTransformOrigin="1.648,0.786" Click="Button2_Click"  />
          
    </Grid>
</UserControl>

MainPage.xaml.cs :

using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ComponentModel;
  
namespace SilverlightApplication1
{
    public partial class MainPage : UserControl, INotifyPropertyChanged
    {
        private List<string> _Data = new List<string>();
        public List<string> Data
        {
            get { return _Data; }
            set
            {
                _Data = value;
                NotifyPropertyChanged("Data");
            }
        }
  
        public event PropertyChangedEventHandler PropertyChanged;
  
        private void NotifyPropertyChanged(String info)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(info));
            }
        }
  
  
        public MainPage()
        {
            InitializeComponent();
            Data.Add("a"); // a small text
        }
  
        private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            Data.Clear();
            Data.Add("a"); // a Small text
            this.grid1.Rebind(); 
        }
  
        private void Button2_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            // TODO: Add event handler implementation here.
            Data.Clear();
            Data.Add("eeeeeeeeeeeeeeeeeeeeeeeeeee"); // a Large text
            this.grid1.Rebind();
        }
  
         
    }
}

Thanks for your help!

Best regards!

2 Answers, 1 is accepted

Sort by
0
Accepted
Tsvyatko
Telerik team
answered on 10 May 2011, 12:32 PM
Hello Olivier,

Thank you for sending us information about this problem. This is a known issue and currently we are working on solution. We will do our best to fix it in one of our next internal builds. Meanwhile you can track its progress in our PITS system - http://www.telerik.com/support/pits.aspx#/public/silverlight/1630

Please, excuse us for the inconvenience caused.

Greetings,
Tsvyatko
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Jean
Top achievements
Rank 1
answered on 10 May 2011, 01:02 PM
Thanks for the answer,

So I'waiting for this bug fix.

Best regards.

Tags
GridView
Asked by
Jean
Top achievements
Rank 1
Answers by
Tsvyatko
Telerik team
Jean
Top achievements
Rank 1
Share this question
or