Data Template

4 posts, 0 answers
  1. Gilbert
    Gilbert avatar
    13 posts
    Member since:
    Oct 2013

    Posted 13 Mar 2014 Link to this post

    I have two questions.

    1. Is there a way to have an item close the expanded grid when another item expands? In other words, I only want one item to expand when a user taps on it and have another item close if expanded.

    2. I have two grids, one on top of another. I would like to have the top grid use the tap event to guide the user to another XAML page, while the bottom grid open the expanded content. This, of course is the Data Template to a DataBound ListBox. I tried moving things around the datatemplate without any success. How can this be accomplished?

    thanks, for your feedback.
  2. Deyan
    Admin
    Deyan avatar
    2037 posts

    Posted 14 Mar 2014 Link to this post

    Hi Gilberto,

    Thanks for writing.

    1. You will need to implement the logic that closes the previously opened expander on your side. It's quite simple - you need to subscribe for the ExpanderStateChanged event within your DataBoundListBox' control template and save a reference to the business object which has been expanded. You can acquire it from the sender argument within the event handler which is of type RadExpanderControl. The Content property of the expander will point to the item from your source. Each time this event comes, you will need to first check if there is already an expanded item, set its IsExpanded property to false and store the newly expanded item on its place.

    2. I am not quite sure if I correctly understand the scenario here. Any further details will be helpful. You can also share some code if you think it might be helpful.

    Thanks for your time.

    Regards,
    Deyan
    Telerik
     

    DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

     
  3. DevCraft banner
  4. Gilbert
    Gilbert avatar
    13 posts
    Member since:
    Oct 2013

    Posted 15 Mar 2014 in reply to Deyan Link to this post

    I will post some code when I get home. Thanks for the reply. Your answer to my first question makes sense.

    Let me explain my second question.
    I have a collection of items on my main page. The ExpanderControl ContentTemplate  has three grid rows.The top grid has a Textblock with the name of the item. The second grid has a textblock with brief details of the item and the third grid is the expandable item.

    I would like the top grid row to link to the details page of the item in the collection when tapped without expanding the third row
    Since the first row is inside the expander control. It expands the third row

    Im sorry if this is not clear, I can post some code.
  5. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 19 Mar 2014 Link to this post

    Hello Gilberto,

    Thanks for writing.
    I suspect your expander is being expanded because the text block does not mark the tap gesture as handled.
    Since you can not inherit from TextBlock (it is sealed) to make it handle the Tap gesture, you can inherit from Button, override OnTap and mark the gesture as handled. Then you can use your button instead. You also have to style it, so that it looks like a text block. Please have a look at the attached app for a simple example.

    Write again if you need further assistance.

    Regards,
    Victor
    Telerik
     

    DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

     
Back to Top