This is a migrated thread and some comments may be shown as answers.

InvalidCastException

2 Answers 130 Views
GridView
This is a migrated thread and some comments may be shown as answers.
David Brenchley
Top achievements
Rank 1
David Brenchley asked on 25 Aug 2011, 04:15 PM
I have a grid that I have set the IsReadOnly to true.  When I am in the grid on any cell, if I press the Enter key, I get the following error.

Unable to cast object of type 'System.Windows.Input.KeyEventArgs' to type 'FullyLoadedCostLibrary.BareDriveCosts'.


StackTrace:
   at Telerik.Windows.Data.FuncExtensions.<>c__DisplayClass1`2.<ToUntypedFunc>b__0(Object item) in c:\TB\102\WPF_Scrum\Release_WPF_40\Sources\Development\Core\Data\Extensions\FuncExtensions.cs:line 24
   at Telerik.Windows.Data.FunctionComparer.Compare(Object x, Object y) in c:\TB\102\WPF_Scrum\Release_WPF_40\Sources\Development\Core\Data\FunctionComparer.cs:line 34
   at System.Collections.Generic.ArraySortHelper`1.InternalBinarySearch(T[] array, Int32 index, Int32 length, T value, IComparer`1 comparer)
   at System.Collections.Generic.ArraySortHelper`1.BinarySearch(T[] array, Int32 index, Int32 length, T value, IComparer`1 comparer)

I'm using version 2011.2.712.40 WPF

My grid is defined
        <telerik1:RadGridView Name="bareDriveCostsListRadGridView"
               DataContext="{StaticResource bareDriveCostsListViewModelModelViewSource}" 
			   ItemsSource="{Binding ValidatesOnDataErrors=True, NotifyOnValidationError=True, ValidatesOnExceptions=True, NotifyOnTargetUpdated=True, NotifyOnSourceUpdated=True}" AutoGenerateColumns="False" CanUserDeleteRows="False"
               AutoExpandGroups="True" DataLoaded="bareDriveCostsListRadGridView_DataLoaded" SelectionUnit="Cell"
               IsReadOnly="{Binding Source={StaticResource bareDriveCostsListViewModelViewSource}, Path=CanEdit, Converter={StaticResource NotConverter}}">


I have some columns defined like this
<telerik1:GridViewMaskedTextBoxColumn Name="HistoryColumn4" DataFormatString="{}{0:n}"  MaskType="Numeric" Mask="n"  Header="{Binding Path=HistoryName4}" Background="LightGray" DataMemberBinding="{Binding Path=History4.Cost}" IsReadOnly="True" TextAlignment="Right"  IsFilterable="False" IsSortable="False" />
and some like this
                <telerik1:GridViewMaskedTextBoxColumn Name="BareDriveCostColumn" Header="Bare Drive Cost" DataMemberBinding="{Binding Path=Cost}" DataFormatString="{}{0:n}" TextAlignment="Right" MaskType="Numeric" Mask="n"  IsFilterable="False" IsSortable="False" >
                    <telerik1:GridViewMaskedTextBoxColumn.CellTemplate>
                        <DataTemplate>
                            <Grid MouseRightButtonDown="Cell_MouseRightButtonDown" DataContext="{Binding}"
                                  ToolTip="{DynamicResource toolTipTemplate}">
                                <TextBlock Text="{Binding Cost}"/>
                                <Border VerticalAlignment="Top" Width="5" Height="5" HorizontalAlignment="Right" Background="Red" Visibility="{Binding Comments,Converter={StaticResource MyConverter}}"/>
                            </Grid>
                        </DataTemplate>
                    </telerik1:GridViewMaskedTextBoxColumn.CellTemplate>                                    
                </telerik1:GridViewMaskedTextBoxColumn>
it errors on any of them.


2 Answers, 1 is accepted

Sort by
0
Accepted
Yordanka
Telerik team
answered on 26 Aug 2011, 09:41 AM
Hello David Brenchley,

Thank you for the feedback.
The exception has already been fixed and the fix for it is part of the latest internal build. 
 
Kind regards,
Yordanka
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
David Brenchley
Top achievements
Rank 1
answered on 26 Aug 2011, 04:05 PM
Awesome.  Thank you.
Tags
GridView
Asked by
David Brenchley
Top achievements
Rank 1
Answers by
Yordanka
Telerik team
David Brenchley
Top achievements
Rank 1
Share this question
or