Get item controls from tileview content

6 posts, 0 answers
  1. Kamal Mostofi
    Kamal Mostofi avatar
    56 posts
    Member since:
    Jan 2010

    Posted 26 Jul 2011 Link to this post

    I designed a form in a tileview content item which customers can send emails to the head office. How can I get the items within the content of tileview? I mean get a textbox value!

  2. Kiril Stanoev
    Kiril Stanoev avatar
    1512 posts

    Posted 27 Jul 2011 Link to this post

    Hello Kamal,

    Could you please tell us how have defined your RadTileView and RadTileViewItems - in XAML or via code (ex. binding)?

    Kiril Stanoev
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  3. Kamal Mostofi
    Kamal Mostofi avatar
    56 posts
    Member since:
    Jan 2010

    Posted 30 Jul 2011 Link to this post

    I defined them in Xaml. 

  4. Tina Stancheva
    Tina Stancheva avatar
    3299 posts

    Posted 03 Aug 2011 Link to this post

    Hi Kamal,

    In this case you can set an x:Name/Name property for each element that you need to access. Setting these properties in XAML identifies the elements in a XAML name-scope. For example if you have the following RadTileView definition:
    <telerik:RadTileView x:Name="tileView">
        <telerik:RadTileViewItem Header="Tile 1">
                <TextBlock x:Name="textBl1" Text="TextBlock1" />
        <telerik:RadTileViewItem Header="Tile 2" Content="Content of Tile 2"/>
    You can access the RadTileViewItem "Tile 1" TextBlock in code-behind through its x:Name property:
    textBl1.Text = "Test";

    Another approach that you can use is to access the TextBlock through the RadTileViewItem.Content property. It holds the content of the tile. This means that the "Tile 1" RadTileViewItem.Content will be an object of type StackPanel. While the "Tile 2" RadTileViewItem.Content will be a string - "Content of Tile 2". This is why you can access the RadTileViewItem "Tile 1" TextBlock in code behind like so:
    RadTileViewItem tile1 = tileView.Items[0] as RadTileViewItem;
    TextBlock txt1 = (tile1.Content as StackPanel).Children[0] as TextBlock;
    txt1.Text = "Test";

    I hope this information will help you. Let us know if we can further assist you.

    Tina Stancheva
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  5. João
    João avatar
    1 posts
    Member since:
    Apr 2014

    Posted 05 Jan 2016 in reply to Tina Stancheva Link to this post

    Hi Tina and Kiril,

    what if I defined my RadTileView and RadTileViewItems via binding?


    Greetings, João

  6. Milena
    Milena avatar
    227 posts

    Posted 08 Jan 2016 Link to this post

    Hi  João,

    You can use the second approach Tina suggested, but when you get the TileViewItem you should cast is to your business class instead of RadTileViewItem: 
    var tile1 = xTileView.Items[0] as CustomerAccount;
    where CustomerAccount is a class from the ViewModel and then you can work with its properties (e.g. email address, name, etc.).

    I hope this information helps.

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top