Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6809961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:08:54+00:00 2026-05-26T20:08:54+00:00

I have a Silverlight app, with a dataGrid in it, I added a TextBox

  • 0

I have a Silverlight app, with a dataGrid in it, I added a TextBox to each row of the DataGrid, on the sixth column, now what I’m trying to accomplish here is, once the user presses the down key, the selected row changes, once it does the focus should be set to the TextBox, so that the user can input data.

Added text box to xaml, like so:

<sdk:DataGridTemplateColumn Header="Confirmation code" Width="Auto">
    <sdk:DataGridTemplateColumn.CellTemplate>
        <DataTemplate>
            <TextBox/>
        </DataTemplate>
    </sdk:DataGridTemplateColumn.CellTemplate>
</sdk:DataGridTemplateColumn>

And added this to the xaml.cs under the DataGrid_SelectionChanged event:

private void BookingsView_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
TextBox content = DataGrid.Columns[6].GetCellContent(DataGrid.SelectedItem) as TextBox;
if (content != null) 
  content.Focus();
}

P.S : additionally, if possible, please suggest me a way, by which I can disable row selection of DataGrid but still, have the focus set to the text box upon keydown navigation..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T20:08:55+00:00Added an answer on May 26, 2026 at 8:08 pm

    To access items inside data template you can use generic VisualTreeHelper method

    private void DataGrid_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            var grid = sender as DataGrid;
            var cell = grid.Columns[6].GetCellContent(grid.SelectedItem).Parent as DataGridCell ;
    
            var textbox = FindFirstElementInVisualTree<TextBox>(cell);
    
                   if(textbox !=null)
                       {
                          textbox.Focus();
                       }
    
    
        }
    
        private T FindFirstElementInVisualTree<T>(DependencyObject parentElement) where T : DependencyObject
        {
            var count = VisualTreeHelper.GetChildrenCount(parentElement);
            if (count == 0)
                return null;
    
            for (int i = 0; i < count; i++)
            {
                var child = VisualTreeHelper.GetChild(parentElement, i);
    
                if (child != null && child is T)
                {
                    return (T)child;
                }
                else
                {
                    var result = FindFirstElementInVisualTree<T>(child);
                    if (result != null)
                        return result;
    
                }
            }
            return null;
        }
    }`
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a HyperLinkButton in every row of a datagrid in my silverlight app.
I have a Silverlight app with a DataGrid containing some custom columns and all
I have a simple Silverlight app which simply sets a DataGrid's ItemsSource to the
I have added a ServiceReference to my Silverlight app. I have called it, WcfServiceReference.
I have a Silverlight app that displays a number of pages. Each page is
I have a silverlight app that will be installed OOB with full trust and
I have a Silverlight app that has to load an image dynamically, depending on
For example: First, say I have a Silverlight app with Windowless=true so that I
I have a small Silverlight app which downloads all of the images and text
I have a Silverlight web app which uses ASP.net Website administration tool for user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.