set VisualElement to textblock inside longlistselector

3 posts, 0 answers
  1. brandon
    brandon avatar
    12 posts
    Member since:
    May 2014

    Posted 06 May 2014 Link to this post

    I'm currently using a longlistselector to update a live tile using LiveTileHelper.  but i'm adding a checkbox in my longlistselector and i do not want that showing up on my tile.  i tried referencing the textblock inside the longlist but that's not working.  is it possible to set the VisualElement to a textblock inside  a longlistselector? or do i need to come up with another method?

    thanks
  2. brandon
    brandon avatar
    12 posts
    Member since:
    May 2014

    Posted 06 May 2014 Link to this post

    i ended up using multiple longlistselectors....seems to work fine.
  3. DevCraft banner
  4. Todor
    Admin
    Todor avatar
    778 posts

    Posted 09 May 2014 Link to this post

    Hi,

    Thank you for your question.

    It is possible to get a TextBlock which is part of the LongListSelector by using our ElementTreeHelper. However, since the TextBlock is part of the ItemTemplate of LongListSelector, you have one TextBlock for each item. If I understand correctly, you want to use all TextBlock-s which are inside the LongListSelector for your tile which is not possible. If this is not the case and you want just one specific TextBlock, here's how you can get it:

    TextBlock t = ElementTreeHelper.FindVisualDescendant<TextBlock>(lstTask, (descendant) =>
        {
            if (!(descendant is TextBlock))
            {
                return false;
            }
            if(((TextBlock)descendant).Text.StartsWith("1"))
            {
                return false;
            }
            return true;
        });

    This call gets the first TextBlock whose Text doesn't start with "1" as an example. If you just need the first TextBlock, you can skip the predicate and use the one parameter overload:

    TextBlock t = ElementTreeHelper.FindVisualDescendant<TextBlock>(lstTask)

    I hope this information helps.

    Regards,
    Todor
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top