Welcome to the Xceed Community | Help
Community Search  
More Search Options

How do I remove the #DIV/0# from the average stat cell?

Sort Posts: Previous Next
  •  06-15-2011, 11:09 AM Post no. 30588

    How do I remove the #DIV/0# from the average stat cell?

    How do I remove the #DIV/0# from the average stat cell when there is no data displayed? I'd quite like it to just display 0.

    Thank you.

    Filed under: ,
  •  06-15-2011, 12:57 PM Post no. 30590 in reply to 30588

    Re: How do I remove the #DIV/0# from the average stat cell?

    Hi Sam, 

    This can be done by changing the DataTemplate of the StatCell and have it display "0" instead of "DIV/0" using a converter.

    Here's an example:

     class StatCellConverter : IValueConverter

        {


            #region IValueConverter Members


            public object Convert(object value, Type targetType, object parameter, CultureInfo culture)

            {

                Debug.WriteLine(value);

                if (value.Equals("#DIV/0#"))

                    return "0";


                return value;

            }


            public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)

            {

                throw new NotImplementedException();

            }


            #endregion

        }

     

     

     <DataTemplate>

                                    <xcdg:StatRow>

                                        <xcdg:StatRow.Cells>

                                            <xcdg:StatCell ResultPropertyName="AverageID"   FieldName="ID">

                                                <xcdg:StatCell.ContentTemplate>

                                                    <DataTemplate>

                                                        <TextBlock Text="{Binding ., Converter={StaticResource ResourceKey=statCellConverter}}"/>

                                                      

                                                    </DataTemplate>

                                                </xcdg:StatCell.ContentTemplate>

                                                

                                            </xcdg:StatCell>

                                        </xcdg:StatRow.Cells>

                                    </xcdg:StatRow>

                                </DataTemplate> 


    Best Regards,

    Michel Dahdah
    Technical Support
    Xceed Software inc.
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.