Getting reference to a text box in a Tile

3 posts, 1 answers
  1. Cuthahotha
    Cuthahotha avatar
    81 posts
    Member since:
    Sep 2008

    Posted 01 Dec 2010 Link to this post

    Assume a multi player word game.  User puts in a word, sends it to the server via web service.  client app polls for new words and put them in the right list box in the right tile. 

    Tiles generated in code based on colleciton or list. (not bound, just iterating the list and adding tiles for each item.) Not many tiles, unusally less than 10.

     Each tile contains a Button, TextBox, and List.  These are defined in XAML. and vary depending on small, large or resized in the fluid content control.

    When the user types in a text box located in a tile, then clicks the button in the same tile, the code in the onclick event needs to find the text box and process the text in the box, and put it in the list box.

    I'm having difficulty getting a handle on the text box in the button click event.

    It doesnt seem to be as easy as iterate over the tiles, and get the text block in the tile... 

    Thoughts?
  2. Answer
    Zarko
    Admin
    Zarko avatar
    755 posts

    Posted 02 Dec 2010 Link to this post

    Hello Cuthahotha,

     You can try to get it with the ChildrenOfType method like that:

    private void Button_Click(object sender, RoutedEventArgs e)
    {
        RadTileViewItem tile = (e.OriginalSource as Button).ParentOfType<RadTileViewItem>();
        if (tile != null)
        {
           TextBox tb = tile.ChildrenOfType<TextBox>().FirstOrDefault();
        }
    }
    If you have further questions feel free to ask.

     

    Best wishes,
    Zarko
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  3. DevCraft banner
  4. Cuthahotha
    Cuthahotha avatar
    81 posts
    Member since:
    Sep 2008

    Posted 14 Dec 2010 Link to this post

    Perfect!  Thanks....
Back to Top