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

[Solved] Focus on Control placed inside GridViewDataColumn of Grid using "MVVM" pattern

0 Answers 191 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
gautham
Top achievements
Rank 1
gautham asked on 18 Nov 2010, 05:09 PM
Hello,

   I am struggling to focus an control placed inside "GridViewDataColumn " of "Grid" using "MVVM" pattern.

   Here I am using an behavior, so that when I press 'Enter' on any cell it will move another "ReadOnly=false" column. but I want to bring back the focus, to the present column which I have edited, when I type wrong data.

Similarly, when new row is added. I should focus to first cell.

Here, I want to play with focusing on required cell, Please assist me.

    I have attached an CodeSnippet which I am working with:

<syncControls:GridView  x:Name="gvGRN"  
                  ItemsSource="{Binding GRNProductAndGRNSubProducts, Mode=TwoWay}"
                  SelectedItem="{Binding GRNProductAndGRNSubProduct, 
                  >
               <i:Interaction.Behaviors>
                   <commonBehavior:CustomKeyboardCommandBehavior>
                   </commonBehavior:CustomKeyboardCommandBehavior>
                   <cmds:UpdateValueBehavior />
               </i:Interaction.Behaviors>
               <syncControls:GridView.Columns>
                     <syncControls:GridViewDataColumn Header="Barcode">
                       <syncControls:GridViewDataColumn.CellTemplate>
                           <DataTemplate>
                               <TextBlock Name="acbBarcode" Text="{Binding Barcode, Mode=TwoWay}"/>
                           </DataTemplate>
                       </syncControls:GridViewDataColumn.CellTemplate>
                       <syncControls:GridViewDataColumn.CellEditTemplate>
                           <DataTemplate>
                               <syncControls:AutoCompleteBox Name="acbBarcodeCode"
                                 Text="{Binding Barcode, Mode=TwoWay}"
                                 ValueMemberBinding="{Binding Barcode, Mode=TwoWay}" 
                                 ItemsSource="{Binding Barcodes, Mode=TwoWay, Source={StaticResource GRNStaticResources}}"
                                 cmds:AutoCompletePopulating.Command="{Binding ACBBarcodeCodePopulatingCommand, Source={StaticResource GRNStaticResources}}"
                                 cmds:AutoCompletePopulating.CommandParameter="{Binding RelativeSource={RelativeSource Self}}"
                                 cmds:UIElementKeyDown.Command="{Binding GetsBarcodeInfoCommand, Source={StaticResource GRNStaticResources}}"
                                 cmds:UIElementKeyDown.CommandParameter="{Binding RelativeSource={RelativeSource Self}}"
                                 cmds:UIElementKeyDown.Key="Enter"
                               >
                                   <syncControls:AutoCompleteBox.ItemTemplate>
                                       <DataTemplate>
                                           <TextBlock Text="{Binding Barcode}"></TextBlock>
                                       </DataTemplate>
                                   </syncControls:AutoCompleteBox.ItemTemplate>
                               </syncControls:AutoCompleteBox>
                           </DataTemplate>
                       </syncControls:GridViewDataColumn.CellEditTemplate>
                   </syncControls:GridViewDataColumn>
               </syncControls:GridView.Columns>
           </syncControls:GridView>

Regards,
Gautham
Tags
GridView
Asked by
gautham
Top achievements
Rank 1
Share this question
or