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

Grid is Crashing Tablet PC

1 Answer 36 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Rayne
Top achievements
Rank 1
Rayne asked on 09 Sep 2011, 04:06 PM
I have a RadGridView in my application that is crashing the application on a select few tablet pc running Windows XP tablet editiion. Because our (state) department is going the tablet way, I really need to get this fixed. Not just disable tablet input services on the pc.
I'm thinking the problem is because the grid that is causing the problem is heavily customized with Data Templates.

The crash happens when they attempt to scroll horizontally on an editable grid. It's been reported that if InsertRows and DeleteRows is disabled, then the grid behaves normally. So far this error has only been reported by users running on a tablet pc.

Also, another user reported that when he tried to activate the TabItem where this grid lives, the application crashed only when there were items bound to the grid. If the bound collection had no items, it didn't crash. His problem was resolved by disabling Tablet Input Services on his Windows 7 tablet pc.

Could someone look at my code and see if I've done something I shouldn't.
<telerik:RadGridView AutoGenerateColumns="False" ShowGroupPanel="False" Margin="15" x:Name="ActionsGridView"
    ItemsSource="{Binding ActionsTaken}" ColumnWidth="Auto"
     SelectionMode="Extended" CanUserDeleteRows="{Binding DataContext.CanEditActions, ElementName=ResolutionsControl}"
                                 CanUserInsertRows="{Binding DataContext.CanEditActions, ElementName=ResolutionsControl}"
                                 ShowInsertRow="{Binding DataContext.CanEditActions, ElementName=ResolutionsControl}"
                                 SelectedItem="{Binding DataContext.SelectedAction, ElementName=ResolutionsControl, Mode=TwoWay}"
                                 IsSynchronizedWithCurrentItem="True"
                                 ValidatesOnDataErrors="InViewMode"
                                 AddingNewDataItem="RadGridView_AddingNewDataItem" EnableColumnVirtualization="False" EnableRowVirtualization="False">
           <telerik:RadGridView.FilterDescriptors>
               <radData:FilterDescriptor Member="IsDeleted" Value="false" Operator="IsEqualTo" />
           </telerik:RadGridView.FilterDescriptors>
           <i:Interaction.Triggers>
               <i:EventTrigger EventName="Deleting">
                   <cmd:EventToCommand PassEventArgsToCommand="True" Command="{Binding DataContext.DeletingAction, ElementName=ResolutionsControl}" />
               </i:EventTrigger>
           </i:Interaction.Triggers>
           <telerik:RadGridView.Columns>
               <telerik:GridViewColumn CellTemplate="{StaticResource DeleteCellTemplate}" />
               <telerik:GridViewComboBoxColumn Header="Action" UniqueName="Action" DataMemberBinding="{Binding ActionID, Mode=TwoWay, ValidatesOnDataErrors=True}"
SelectedValueMemberPath="ActionID" DisplayMemberPath="Name" ItemsSource="{Binding DataContext.Actions, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UserControl,AncestorLevel=2}}"
                                               IsComboBoxEditable="True">
               </telerik:GridViewComboBoxColumn>
               <telerik:GridViewDataColumn Header="Date of Action" UniqueName="ActionDate" DataMemberBinding="{Binding DateActionTaken, StringFormat={}{0:d}, ValidatesOnDataErrors=True,UpdateSourceTrigger=PropertyChanged}">
                   <telerik:GridViewDataColumn.CellTemplate>
                       <DataTemplate>
                           <TextBlock Text="{Binding DateActionTaken, StringFormat={}{0:d}, ValidatesOnDataErrors=True}" />
                       </DataTemplate>
                   </telerik:GridViewDataColumn.CellTemplate>
                   <telerik:GridViewDataColumn.CellEditTemplate>
                       <DataTemplate>
                           <telerik:RadDatePicker SelectedValue="{Binding DateActionTaken, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
                             SelectableDateEnd="{Binding Source={x:Static System:DateTime.Now}}"
                             SelectableDateStart="{Binding DataContext.Complaint.DateReceived, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UserControl,AncestorLevel=2}}" />
                       </DataTemplate>
                   </telerik:GridViewDataColumn.CellEditTemplate>
               </telerik:GridViewDataColumn>
               <telerik:GridViewDataColumn Header="Action By" DataMemberBinding="{Binding ActionByUserID}" MinWidth="120">
                   <telerik:GridViewDataColumn.CellTemplate>
                       <DataTemplate>
                           <TextBlock Text="{Binding ActionBy.FullName}" />
                       </DataTemplate>
                   </telerik:GridViewDataColumn.CellTemplate>
                   <telerik:GridViewDataColumn.CellEditTemplate>
                       <DataTemplate>
                           <StackPanel VerticalAlignment="Stretch" Orientation="Horizontal">
                               <TextBlock Margin="3,0" MinWidth="104"
                                                  Text="{Binding ActionBy.FullName, ValidatesOnDataErrors=True}" />
                               <telerik:RadButton Command="{Binding DataContext.ShowUsersPopup, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UserControl,AncestorLevel=2}}">
                                   <Image Source="/Complaints.Common;component/Images/magnifier.png" />
                               </telerik:RadButton>
                           </StackPanel>
                       </DataTemplate>
                   </telerik:GridViewDataColumn.CellEditTemplate>
               </telerik:GridViewDataColumn>
               <telerik:GridViewDataColumn DataMemberBinding="{Binding Comments}" Header="Comments" UniqueName="ActionComments" TextWrapping="Wrap" Width="300"
                                                CellEditTemplate="{StaticResource CommentEditorTemplate}">
                   <telerik:GridViewDataColumn.CellTemplate>
                       <DataTemplate>
                           <TextBlock Width="300" Text="{Binding Comments}" TextWrapping="Wrap" />
                       </DataTemplate>
                   </telerik:GridViewDataColumn.CellTemplate>
               </telerik:GridViewDataColumn>
               <telerik:GridViewDataColumn DataMemberBinding="{Binding UserCreated}" Header="Recorded by" IsReadOnly="True" />
               <telerik:GridViewDataColumn DataMemberBinding="{Binding DateCreated}" Header="Date/Time Recorded" IsReadOnly="True" />
           </telerik:RadGridView.Columns>
       </telerik:RadGridView>

1 Answer, 1 is accepted

Sort by
0
Rayne
Top achievements
Rank 1
answered on 09 Sep 2011, 04:14 PM
The CellEditTemplate for the Cell bound to Comments is below. The Data Context is set in the RadContextMenu Opened Event because the grid is on a User Control that itself is a DataTemplate for a RadTabItem. So the DataContext is incorrect when the grid is bound. But since the contextr menu isn't part of the visual tree, I couldn't use relative source to find it right members to bind to. 
<DataTemplate x:Key="CommentEditorTemplate">
            <TextBox Text="{Binding Comments, UpdateSourceTrigger=PropertyChanged}" TextWrapping="Wrap" Width="300" SpellCheck.IsEnabled="True" ContextMenu="{x:Null}" Name="CommentBox">
                <telerik:RadContextMenu.ContextMenu>
                    <telerik:RadContextMenu Opened="RadContextMenu_Opened">
                        <telerik:RadMenuItem Header="Cut" Command="Cut" />
                        <telerik:RadMenuItem Header="Copy" Command="Copy" />
                        <telerik:RadMenuItem Header="Paste" Command="Paste" />
                        <telerik:RadMenuItem IsSeparator="True" />
                        <telerik:RadMenuItem Header="Quick Comments" ItemsSource="{Binding QuickComments}" DisplayMemberPath="Item">
                        </telerik:RadMenuItem>
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="ItemClick">
                                <cmd:EventToCommand Command="{Binding AppendQuickComments}"
                                                    PassEventArgsToCommand="True" />
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </telerik:RadContextMenu>
                </telerik:RadContextMenu.ContextMenu>
            </TextBox>
        </DataTemplate>
Tags
GridView
Asked by
Rayne
Top achievements
Rank 1
Answers by
Rayne
Top achievements
Rank 1
Share this question
or