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 :
MainPage.xaml.cs :
Thanks for your help!
Best regards!
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!