Search code examples
c#xamlwindows-phone-8expanderwptoolkit

Prevent ExpanderView from expanding on click or overwrite expand method


I have a list of toolkit:ExpanderViewelements that should expand on click/tap. But their content was quite big so I wanted to load it after clicking/tapping. So in the UI-event I load the content but it opens only a bit, like there is no content to show. After closing and opening again it is working.

I guess the ExpanderView doesn't wait for my UI-event handling method but just starts expanding automatically. If I try to close it, load and open it again it just closes. I guess it's too much actions because it is open-close-open.

Is there a way to overwrite the expand method or to prevent the auto-expand and do it on my own?

https://github.com/nokiadatagathering/WP7-Official/blob/master/Microsoft.Phone.Controls.Toolkit/ExpanderView/ExpanderView.cs <- is this the same file I have in my toolkit? Where can I find and edit it on my Pc?

Edit:

As I see now, there is no way to update the ExpanderView except expanding and collapsing it :(

I managed to set it HitTestVisible = False, but it inside the button and there I can load the expanded part and THEN set it to IsExpanded = True. But as it doesn't update the Height..... I don't know what else to do with it..


Solution

  • That is not nice but it works:

    I Tap my ExpanderView, it wants to open automatically. At the same time I start a "Tap"-Event that loads the needed content in the ViewModel of the clicked Expanderview and after it's loaded I use

    contact.IsExpanded = false;
    exp.UpdateLayout();
    contact.IsExpanded = true;
    

    It's not nice. But it loads the stuff I need after clicking and not when loading the whole view and it expands with the new content without stuttering.