This question is locked. New answers and comments are not allowed.
Hi
The following code extract is from Examples.GridView.DataFormatting.
I need to do the highlighted xaml in c# code-behind. Following the extract is my lame attempt at the code-behind. Can you show me how to write the code-behind>
Thanks
Rich
<Grid.Resources>
<local:MyConverter x:Key="myConverter" />
</Grid.Resources>
<telerik:GridViewDataColumn Header="Discontinued" DataMemberBinding="{Binding Discontinued}">
<telerik:GridViewDataColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Discontinued, Converter={StaticResource myConverter}}" />
</DataTemplate>
</telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>
public class MyConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return ((bool) value) ? "yes" : "no";
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return value;
}
}
=================================================================
my code-behind
=================================================================
gridViewDataColumn.DataMemberBinding = new Binding(col.UniqueName);
TextBlock Text = new TextBlock();
Binding binding = new Binding(col.UniqueName);
binding.Path = new PropertyPath("Global.YesNoConverter");
Text.SetBinding(TextBlock.TextProperty, binding);
?????? gridViewDataColumn.CellTemplate ???????????
The following code extract is from Examples.GridView.DataFormatting.
I need to do the highlighted xaml in c# code-behind. Following the extract is my lame attempt at the code-behind. Can you show me how to write the code-behind>
Thanks
Rich
<Grid.Resources>
<local:MyConverter x:Key="myConverter" />
</Grid.Resources>
<telerik:GridViewDataColumn Header="Discontinued" DataMemberBinding="{Binding Discontinued}">
<telerik:GridViewDataColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Discontinued, Converter={StaticResource myConverter}}" />
</DataTemplate>
</telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>
public class MyConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return ((bool) value) ? "yes" : "no";
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return value;
}
}
=================================================================
my code-behind
=================================================================
gridViewDataColumn.DataMemberBinding = new Binding(col.UniqueName);
TextBlock Text = new TextBlock();
Binding binding = new Binding(col.UniqueName);
binding.Path = new PropertyPath("Global.YesNoConverter");
Text.SetBinding(TextBlock.TextProperty, binding);
?????? gridViewDataColumn.CellTemplate ???????????