Expander control

I have a couple of questions about the Expander control.

1 - Is it just me or does the expand button on the header seem backwards to anyone else The arrow pointing up is when the panel is expanded and the arrow pointing down is when the panel is collapsed.

2- Is there a way to actually have the content panel expand and collapse It seems to me that the control should behave that way out of the box. Is this a known issue or the designed behavior of the control. Either way anyone have a quick tip on how to expand/collapse the control. An animation example would be great if you have that :D

Thanks!



Answer this question

Expander control

  • Ifti

    Hi Matt,

    Good point - this is a known issue in the March CTP. My apologies - I should have mentioned this - our Control template editing story was a little broken in that CTP - however, this has been fixed for our next public release - we don't have a release date for it though.

    Thanks,
    -Unni



  • U3Bunji

    Heh! That's exacly what I did when I first noticed the behavior of the arrow in the header. While changing this using EID wasn't very difficult to do I was expecting the arrow to behave differently. I also wanted to register my feedback on the forum for WPF team members to see and for other developers to chime in on if they felt the same way.

    I've taken a look at the Expander control template you posted and the behavior of the content area is what I expected to occur with the control out of the box. It looks like all that was needed was the trigger setting the ExpandSite visibility based on the IsExpanded property. Is this correct Are there plans to update this control to include this behavior

    I'm also going to take a shot at animating the ExpandSite. I'll post any findings that I come up with and would appreciate anyone else doing the same.


  • larryj

    Curious ... you imply (I think) that this is a bug in EID, but if I programmatically obtain the XAML for an Expander's Template by passing it to this C# method:

    public static String GetControlTemplateText(ControlTemplate controlTemplate)
    {
    StringBuilder
    sb = new StringBuilder();
    using (TextWriter writer = new StringWriter(sb))
    {
    System.Windows.Markup.
    XamlWriter.Save(controlTemplate, writer);
    }
    return sb.ToString();
    }

    then the XAML I get back has exactly the same problem -- namely, that there's no Binding between the ToggleButton's IsChecked property and the Expander's IsExpanded property.

    I've used this method successfully in the past for other controls (before I started using EID :-) and never had a problem like this. I imagine EID must be doing something similar.

    In other words, it seems like it's a WPF bug, not an EID bug. Or is the process of obtaining a control's default ControlTemplate more involved that I've made it out


  • VcDeveloper

    1.
    <joke> This is so to give you a chance to explore the power of the platform - just pull up Expression Interactive Designer and change the way the arrow works :)
    </joke>

    2. I tried changing the behavior of the Expander control to make it do what you want using Expression Interactive Designer again - I did not have time to get to the animation yet, but you can find a simple version here: http://home.comcast.net/~unnir/samples/Expander.xaml

    Thanks,
    -unni



  • WoayChee

    You are correct - the fix that I implied did not require any changes to EID - we were depending on WPF to do the right thing which will happen in the next release. While we do more than simply serialize the control template, the underlying cause is the same as the one you point out.

    Thanks,
    -Unni



  • IMustCode

    I don't know about you guys, but in EID, when I create a copy of the Expander template to edit, the expanded content no longer appears when I click on the Expander. (The original post seems to imply a similar problem.)

    I did some investigation, and for some reason, the ControlTemplate is missing a Binding between the ToggleButton's IsChecked property and the Expander's IsExpanded property.

    Add this attribute to the ToggleButton itself in the (copy of) the Expander's ControlTemplate:

    IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=IsExpanded}"

    and it should work. You'll have to add this in the XAML code itself, of course.

    I don't know why the Expander's ControlTemplate doesn't contain this Binding. Maybe it's added programmatically at some point (which seems like the wrong way to do it).


  • Expander control