This question is locked. New answers and comments are not allowed.
I have a cell template that contains several items: Two images and one text box.
The images optionally are displayed based on a condition and the text box is always visible. However, I cannot seem to get the with to stretch to the full size of the cell template. I have tried both WrapPanels and Grids and neither works.
I have found that it appears to be related to the fact that I am not specifically setting the width of the cell. When I set it to some value, then the text box seems to stretch as expected, but unfortunately, I need the width of the column to be auto sized based on the content (i.e. if the images need to be shown, then it should auto expand).
What can I do to make the text box expand to the full width of the gridview cell?
Or, is there a better way to do what I am attempting?
Here is my XAML code:
The images optionally are displayed based on a condition and the text box is always visible. However, I cannot seem to get the with to stretch to the full size of the cell template. I have tried both WrapPanels and Grids and neither works.
I have found that it appears to be related to the fact that I am not specifically setting the width of the cell. When I set it to some value, then the text box seems to stretch as expected, but unfortunately, I need the width of the column to be auto sized based on the content (i.e. if the images need to be shown, then it should auto expand).
What can I do to make the text box expand to the full width of the gridview cell?
Or, is there a better way to do what I am attempting?
Here is my XAML code:
<
telerik:GridViewDataColumn
Header
=
"Base Price"
HeaderTextAlignment
=
"Center"
MinWidth
=
"50"
>
<
telerik:GridViewDataColumn.CellTemplate
>
<
DataTemplate
>
<
Grid
>
<
Grid.ColumnDefinitions
>
<
ColumnDefinition
Width
=
"Auto"
></
ColumnDefinition
>
<
ColumnDefinition
Width
=
"Auto"
></
ColumnDefinition
>
<
ColumnDefinition
Width
=
"*"
></
ColumnDefinition
>
</
Grid.ColumnDefinitions
>
<
Image
Source
=
"/PriceBook;component/Images/Pencil.png"
Grid.Column
=
"0"
Visibility
=
"{Binding BasePrice.IsPriceChanged, Converter={StaticResource VisibilityConverter}}"
/>
<
Image
Source
=
"/PriceBook;component/Images/Override.png"
Grid.Column
=
"1"
Visibility
=
"{Binding BasePrice.IsPriceOverride, Converter={StaticResource VisibilityConverter}}"
/>
<
TextBox
Grid.Column
=
"2"
HorizontalAlignment
=
"Stretch"
HorizontalContentAlignment
=
"Stretch"
Text
=
"{Binding BasePrice.Current, Mode=TwoWay, Converter={StaticResource PriceConverter}}"
BorderThickness
=
"0"
Background
=
"Transparent"
Foreground
=
"{Binding BasePrice.Foreground}"
ToolTipService.ToolTip
=
"{Binding BasePrice.ToolTipText}"
TextAlignment
=
"Right"
></
TextBox
>
</
Grid
>
</
DataTemplate
>
</
telerik:GridViewDataColumn.CellTemplate
>
</
telerik:GridViewDataColumn
>