Hi,
I seem to have a small problem when data binding a RadGridView Control with a Data Table via a Boolean Converter. The scenario is as follows .... I have a DataTable of which one of the columns is of type Boolean. I would like to convert the True value to YES and False to NO. When I bind the DataColumn of the grid via a Converter class, no value is displayed. However, when I click on the filter icon of the column I can filter by YES and NO. I have gone through the forums and documentation and applied the solutions to similar problems with no success.
Converter Class
XAML
I seem to have a small problem when data binding a RadGridView Control with a Data Table via a Boolean Converter. The scenario is as follows .... I have a DataTable of which one of the columns is of type Boolean. I would like to convert the True value to YES and False to NO. When I bind the DataColumn of the grid via a Converter class, no value is displayed. However, when I click on the filter icon of the column I can filter by YES and NO. I have gone through the forums and documentation and applied the solutions to similar problems with no success.
Converter Class
[ValueConversion(
typeof
(Boolean),
typeof
(String))]
class
IsWhiteAreaConverter : IValueConverter
{
public
object
Convert(
object
value, Type targetType,
object
parameter, System.Globalization.CultureInfo culture)
{
return
(
bool
)value ?
"Yes"
:
"No"
;
}
public
object
ConvertBack(
object
value, Type targetType,
object
parameter, System.Globalization.CultureInfo culture)
{
if
((
string
)value ==
"Yes"
)
{
return
true
;
}
else
{
return
false
;
}
}
}
XAML
<
Grid.Resources
>
<
my:IsWhiteAreaConverter
x:Key
=
"isWhiteAreaConverter"
/>
</
Grid.Resources
>
<telerik:RadGridView Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2" Name="rgvPlan" ItemsSource="{Binding}" AutoGenerateColumns="False">
<
telerik:GridViewDataColumn
Header
=
"HalfLevel"
DataMemberBinding
=
"{Binding HalfLevelName}"
/>
<
telerik:GridViewDataColumn
Header
=
"Is White Area"
DataMemberBinding
=
"{Binding IsWhiteArea, Converter={StaticResource isWhiteAreaConverter}}"
>
<
telerik:GridViewDataColumn.CellTemplate
>
<
DataTemplate
>
<
TextBlock
Text
=
"{Binding IsWhiteArea, Converter={StaticResource isWhiteAreaConverter}, Mode=Default}"
Foreground
=
"AliceBlue"
/>
</
DataTemplate
>
</
telerik:GridViewDataColumn.CellTemplate
>
<
telerik:GridViewDataColumn.CellEditTemplate
>
<
DataTemplate
>
<
TextBox
Text
=
"{Binding IsWhiteArea, Converter={StaticResource isWhiteAreaConverter}}"
/>
</
DataTemplate
>
</
telerik:GridViewDataColumn.CellEditTemplate
>
</
telerik:GridViewDataColumn
>