locked
ContentControl with ContentTemplateSelector, reuse of view? RRS feed

  • Question

  • Hello everybody,

      I have a ContentControl that uses a template selector based on a selected GridViewItem.  For unique data types, the view in the Content control behaves correctly.  However, there is a data type that can be added multiple times to the gridview. 

    For example, a single Doctor, Engineer, and Lawyer are in the GridView.  However, multiple Assistants can be in the gridview.  The views bind data correctly to the ContentControl, but when there are multiple Assistants, the views for the Assistant data type seem to be reused instead of being distinct.  Is there anyway to get around this?  I need the Assistant views to be distinctly created and not reused.

    Thursday, September 26, 2013 5:05 PM

Answers

  • This would be controlled by your code. It is definitely possible (and typical) for each item to have different data. The standard behavior (without the template selector) is for each item to use the same template. The template selector may choose different ones for different items, but it shouldn't have any trouble using the same template on multiple items.

    If you need more specific help can you please provide more details about what your code is doing? Can you upload a minimal sample to your SkyDrive and include directions on how to reproduce the problem and how the actual behavior differs from the expected behavior?

    --Rob

    Friday, September 27, 2013 1:42 AM
    Moderator

All replies

  • This would be controlled by your code. It is definitely possible (and typical) for each item to have different data. The standard behavior (without the template selector) is for each item to use the same template. The template selector may choose different ones for different items, but it shouldn't have any trouble using the same template on multiple items.

    If you need more specific help can you please provide more details about what your code is doing? Can you upload a minimal sample to your SkyDrive and include directions on how to reproduce the problem and how the actual behavior differs from the expected behavior?

    --Rob

    Friday, September 27, 2013 1:42 AM
    Moderator
  • Hi, Rob

       What's happening is that we've attached a behavior to a textbox on the view.  The one's that are singleton works as desired, but the ones that can have multiples (as in the Assistant object example above) only attach the behavior once instead of each time for each Assistant.  I'll try to whip up an example and put it on my SkyDrive.  Thanks.

    Friday, September 27, 2013 4:09 PM
  • Hi Rob, sorry for getting back to you so late.  We've narrowed down the issue to the way our attached behavior is handling the use of the same data template.  However, we haven't found a solution.  We're hoping 8.1's behavior framework will work for us.  Thanks again.
    Thursday, October 24, 2013 8:35 PM