I have a GridView that has 3 columns. However, the host Grid needs to be just the width of the 1st column. I have bound the column's Width Property to my Model View as shown:
<
telerik:GridViewDataColumn
Header
=
"Name"
DataMemberBinding
=
"{Binding Name}"
Width
=
"{Binding NameColumnWidth}"
IsReadOnly
=
"True"
/>
However, the Cell should resize only based on the content size so it is defined as SizeToCells:
private
GridViewLength _nameColumnWidth =
new
GridViewLength(0, GridViewLengthUnitType.SizeToCells);
[Display(
AutoGenerateField=
false
)]
[System.Xml.Serialization.XmlIgnore]
public
GridViewLength NameColumnWidth
{
get
{
return
_nameColumnWidth; }
set
{
if
(_nameColumnWidth != value)
{
_nameColumnWidth = value;
notifyPropertyChanged(
"NameColumnWidth"
);
}
}
}
How can I set the grid width to match the width of the name column's width? Is there a converter that takes the AutoSize value from the column and converts it to Pixels? Or, can I set the System.Windows.GridLength = NameColumnWidth? Can I do this another way if I don't use SizeToCells?