开发者

WPF Accordion control within a popup

I'm using an Accordion control as per this link - Is there a WPF control I can use to expand/collapse panels (animated)

The problem is that I'd like this control to be hosted by a Popup. Problem is that the Popup does not get resized when I expand any of the groups. If I give the popup a fixed size, then the items get expanded, but it's an ugly effect, because the first time you see a large popup with a few collapsed items on top. Would rather have the popup resizing as the items expand and/or collapse.

Any suggestions?

Thanks.

EDIT: Looks like I totally got it wrong. I didn't need to use the Accordion control. Have just put the expanders within a grid, giving each row Height="Auto". The popup resize开发者_如何学编程s nicely when expanding/collapsing the groups.


I really hate WPF's default Popup, so usually use my own. The code for it can be found here

The default size of the Popup Content is based on the size of the content inside the popup. Here's a rough example of how it can be used:

<local:PopupPanel
    local:PopupPanel.PopupParent="{Binding ElementName=PopupParentPanel}"
    local:PopupPanel.IsPopupVisible="{Binding IsPopupVisible}">

    <DockPanel>
        <Label DockPanel.Dock="Top" Background="Silver" Content="Popup Header" />
        <Button DockPanel.Dock="Bottom" Content="Save" />
        <local:MyUserControl DataContext="{Binding }" />
    </DockPanel>

</local:PopupPanel>


You could set height of the popup using binding to the ActualHeihgt property of your accordion control.

It will look like that:

<Popup Height="{Binding ElementName=myAccordion,Path=ActualHeight" >
 <Accordion x:Name="myAccordion">
  ...
 </Accordion>
</Popup>

But you'll definitely to set a height limit. Could be solved using converter with parameter.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜