none
Accordion in Silverlight

    Question

  • Iam working on a simpel accordion control for Silverlight 2.0 RC0.
    it is a simpel version and i got it working with 1 item. (a folding menu if you want to call it like that)

    What i want to do is to place 3 foldingmenu's under eachother. When you click on 1 it will fold open and data will appear in it. While doing this the foldingmenu's which are under it will move to the bottom of the page. (below you see a simple ASCI example)

    All closed:
    ========V
    ========V
    ========V

    Middle one open:
    ========V
    ========^
     |            |
     |   abc    |
     |            |
     |_______|
    ========V

     i hope you all get the idea.

    What i got now is that those menu's are a Own UserControl with States in them.
    When i add a foldmenu to my LayoutRoot grid the states work like a charm. But when i place it in a StackPanel the 'foldingpart' (where the abc is placed in the example) wont get shown.

    So i tried to place it in a grid, but by doing that (with different grid.rows) the foldingmenu's wont be placed directly undereachother but seperated.

    I have searched on the internet but all i can find is http://www.codeplex.com/iTunes2/Release/ProjectReleases.aspx?ReleaseId=7382 which is based on Silverlight 1.? something. and i cant get it to convert.

     My code:
    Page.xaml.cs

    1        m_MenuOne = new Menu(this);
    2        m_MenuTwo = new Menu(this);
    3        m_MenuThree = new Menu(this);
    4        
    5        this.FoldingMenuStackPanel.Children.Add(m_MenuOne);
    6        this.FoldingMenuStackPanel.Children.Add(m_MenuTwo);
    7        this.FoldingMenuStackPanel.Children.Add(m_MenuThree);
    
     
    I make 3 menu's here and add them to the page.
    Menu.xaml.cs
     
    1        private void OnFoldButtonMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
    2                {
    3                    if(m_Open)
    4                    {
    5                        VisualStateManager.GoToState(this, "Closed", false);
    6                        m_Open = false;
    7                    }
    8                    else
    9                    {
    10                      VisualStateManager.GoToState(this, "Open", false);
    11                      m_Open = true;
    12                  }
    13              } 
    14   
    
     

    I have a boolean where i can check wether the menu is open or not.

    How comes that it doesnt work when i place multiple (but also at one menu) menu's in a stackpanel.

    if i gave to little information i would like to now, i would try to add some more than.
    Thanks in advance.
    Ferdy Griffioen

    Thursday, October 09, 2008 10:30 AM

Answers

  • i fixed it. it had something to do with the fact that the drop out 'abc' part cannot be Strech but has to be a fixed value.

    thnx for the help Harsh.

    Friday, October 10, 2008 7:45 AM

All replies

  • Hi,

    Why don't you Place them in Canvas.

    There you have to write some extra logic of Positioning but i think there that will work fine....

    Thursday, October 09, 2008 10:33 AM
  • Hi,

    Why don't you Place them in Canvas.

    There you have to write some extra logic of Positioning but i think there that will work fine....

     

    Well ive tried that but i have no clue how to position it as the page they go on to is dynamic in the hight. So the fallout part (the abc part in example) is different in height according to the size of the page.

    Personally i find it much nicer (and less dirty code) to do it dynamicly in a stackpanel or grid, but that is a nogo for me atm.

     thnx for the input.

    Thursday, October 09, 2008 11:59 AM
  • Hi Hopefully You can try like this.

    1)Put your canvas inside another canvas.

    2)Inside your Child Canvas Place your Controls.

    3)Your Every user control will be having some handling events which will Resize it.At that time change height of ParentCanvas of that Particular Panel control and that Particular Panel which has been clicked  and show only that Particular Part which you want to show and change Canvas.Top property of Othertwo panel control accordingly.

    hopefully it will help you.

    Thursday, October 09, 2008 12:11 PM
  • I got part of it working atm.

    What i now have is a StackPanel with in that 3 times a canvas. When i open the first menu the other drop down to the bottom of the page. this all works perfectly now.

    But, the 'abc' part is still not showing. If i place the menu seperately in the LayoutRoot grid it works, but in that canvas it doesnt.

    What can this be, some sort of refresh of the canvas or something

    PS: a second visual change in my statemanager works fine (its the change of a textbox.text). its just the 'abc' part of the visualstatemanager that doesnt show

    Friday, October 10, 2008 6:40 AM
  • i fixed it. it had something to do with the fact that the drop out 'abc' part cannot be Strech but has to be a fixed value.

    thnx for the help Harsh.

    Friday, October 10, 2008 7:45 AM
  •  By the way, you might want to consider waiting a bit:

     

    Here's a list of the Silverlight controls we are currently working on that we think will be ready.  We are working on some other components as well, but I'm leaving them off the list until we have higher-confidence about them being ready:

    • DockPanel
    • WrapPanel
    • ViewBox
    • Label
    • HeaderedContentControl
    • Expander
    • TreeView
    • NumericUpDown
    • AutoComplete
    • Accordion

    source: http://blogs.msdn.com/sburke/archive/2008/09/17/control-freak.aspx

     

    Friday, October 10, 2008 7:57 AM
  • it depends when that is released, cause i need it kinda now Stick out tongue

    so i work with my own one, and when its released i can switch

    Friday, October 10, 2008 8:51 AM
  •  from the teleconference about the new Silverlight, it was mentioned the controltoolkit (including the accordeon) will be released this month. Not sure that fits with your schedule... Smile

     

    see this thread: http://silverlight.net/forums/t/36325.aspx and my blog.

    Monday, October 13, 2008 5:45 PM
  • ive ready the release post yeah, we will see what it all brings.

    Tuesday, October 14, 2008 2:56 AM