In my GridView I have a column which shows numeric values. If the value is zero (0) I would like to replace that value with a dash ("-"). Is there a way to do that in the xaml using the DataFormatString method, or ResultFormatString method?
Thank you in advance.
5 Answers, 1 is accepted
The easiest way to do that is to make a small IValueConverter and use it in the DataMemberBinding of the column.Within the Convert method you may write th logic to return the "-" when the value is 0.
Let me know in case you need a sample on this.
Greetings,
Pavel Pavlov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
I would appreciate an example on how to do this, please.
Actually we have this demonstrated in our QSF. Please have a look at this online example.
The "Discontinued" column uses an IValueConverter to display different content in the cell depending on the input value. Please click the <View Code> button to see the implementation of the IValueConverter.
For your case you will need to slightly alter the Convert method so that when the value is 0 -> return "-" else return the value itself.
Regards,
Pavel Pavlov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns
:controls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"
xmlns:telerik="clr-namespace:Telerik.Windows.Data;assembly=Telerik.Windows.Data" x:Class="SES.UI.Silverlight.OnScreenReports.SES027ResultsScreen"
xmlns:telerikPresentation="http://schemas.telerik.com/2008/xaml/presentation"
xmlns:conversion="clr-namespace:SES.UI.Silverlight.OnScreenReports"
>
<Grid x:Name="LayoutRoot">
<Grid.Resources>
<conversion:ConvertZeroToDash x:Key="ZeroConverter"></conversion:ConvertZeroToDash>
</Grid.Resources>
Here is start of the C# code-behind for this screen:
public partial class SES027ResultsScreen : UserControl, IXWindowed<SES027ResultsScreen>{
public SES027ResultsScreen(){
InitializeComponent();
}
Thank you...