如何在xaml中向Accordion添加多个用户控件

发布于 2024-10-22 02:53:10 字数 677 浏览 1 评论 0原文

我正在使用带有 Accordion 的 Silverlight 4 页面,我试图向每个 Accordion 项目插入 2 个用户控件。

<toolkit:Accordion Name="accordion1">
    <toolkit:AccordionItem Content="item 1" Header="A">
        <local:AddRemoveControl x:Name="AddRemoveAgents" Margin="470,90,0,0">     </local:AddRemoveControl>
    </toolkit:AccordionItem>
    <toolkit:AccordionItem Content="item 2" Header="B -  long header">
        <local:DatesFilter x:Name="DatesFilter" Margin="475,200,0,0" Canvas.Top="76"> </local:DatesFilter>
    </toolkit:AccordionItem>
</toolkit:Accordion>

我收到以下错误消息:“属性内容设置多次”

我该如何继续?

谢谢你!

I'm using a Silverlight 4 page with an Accordion to which I'm trying to insert 2 user controls to each Accordion item.

<toolkit:Accordion Name="accordion1">
    <toolkit:AccordionItem Content="item 1" Header="A">
        <local:AddRemoveControl x:Name="AddRemoveAgents" Margin="470,90,0,0">     </local:AddRemoveControl>
    </toolkit:AccordionItem>
    <toolkit:AccordionItem Content="item 2" Header="B -  long header">
        <local:DatesFilter x:Name="DatesFilter" Margin="475,200,0,0" Canvas.Top="76"> </local:DatesFilter>
    </toolkit:AccordionItem>
</toolkit:Accordion>

I'm getting the following error message: "The property content is set more than once"

How can I proceed?

Thank you!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

椵侞 2024-10-29 02:53:10

手风琴中只能有一个内容项。

您需要做的是将控件包装在 StackPanel 中:

<toolkit:Accordion Name="accordion1">
    <toolkit:AccordionItem Content="item 1" Header="A">
        <StackPanel>
            <local:AddRemoveControl x:Name="AddRemoveAgents" Margin="470,90,0,0"></local:AddRemoveControl>
            <local:DatesFilter x:Name="DatesFilter" Margin="475,200,0,0" Canvas.Top="76"> </local:DatesFilter>
        </StackPanel>
    </toolkit:AccordionItem>
</toolkit:Accordion>

You can only have one content item in an accordion.

What you will need to do is wrap your controls in a StackPanel:

<toolkit:Accordion Name="accordion1">
    <toolkit:AccordionItem Content="item 1" Header="A">
        <StackPanel>
            <local:AddRemoveControl x:Name="AddRemoveAgents" Margin="470,90,0,0"></local:AddRemoveControl>
            <local:DatesFilter x:Name="DatesFilter" Margin="475,200,0,0" Canvas.Top="76"> </local:DatesFilter>
        </StackPanel>
    </toolkit:AccordionItem>
</toolkit:Accordion>
就像说晚安 2024-10-29 02:53:10

这是我更新的代码:

<toolkit:Accordion Canvas.Left="480" Canvas.Top="104" Height="100" Name="accordion1" Width="300">
        <toolkit:AccordionItem Content="item 1" Header="A">
                <StackPanel>
                    <local:AddRemoveControl x:Name="AddRemoveAgents" Margin="470,90,0,0"></local:AddRemoveControl>
                </StackPanel>
            </toolkit:AccordionItem>
        <toolkit:AccordionItem Content="item 2" Header="B -  long header">
                <StackPanel>
                    <local:DatesFilter x:Name="DatesFilter" Margin="475,200,0,0" Canvas.Top="76"></local:DatesFilter>
                </StackPanel>
        </toolkit:AccordionItem>
    </toolkit:Accordion>

Here is my updated code:

<toolkit:Accordion Canvas.Left="480" Canvas.Top="104" Height="100" Name="accordion1" Width="300">
        <toolkit:AccordionItem Content="item 1" Header="A">
                <StackPanel>
                    <local:AddRemoveControl x:Name="AddRemoveAgents" Margin="470,90,0,0"></local:AddRemoveControl>
                </StackPanel>
            </toolkit:AccordionItem>
        <toolkit:AccordionItem Content="item 2" Header="B -  long header">
                <StackPanel>
                    <local:DatesFilter x:Name="DatesFilter" Margin="475,200,0,0" Canvas.Top="76"></local:DatesFilter>
                </StackPanel>
        </toolkit:AccordionItem>
    </toolkit:Accordion>
吻安 2024-10-29 02:53:10

您正在两次定义内容。尝试从 AccordionItem 中删除内容标签,如下所示:

<toolkit:Accordion Canvas.Left="480" Canvas.Top="104" Height="100" Name="accordion1" Width="300">
    <toolkit:AccordionItem Header="A">
            <StackPanel>
                <local:AddRemoveControl x:Name="AddRemoveAgents" Margin="470,90,0,0"></local:AddRemoveControl>
            </StackPanel>
        </toolkit:AccordionItem>
    <toolkit:AccordionItem Header="B -  long header">
            <StackPanel>
                <local:DatesFilter x:Name="DatesFilter" Margin="475,200,0,0" Canvas.Top="76"></local:DatesFilter>
            </StackPanel>
    </toolkit:AccordionItem>
</toolkit:Accordion>

另外,按照当前的方式,您最终将得到两个 Accordion 项目,每个项目中都有一个控件。要将两个控件放在同一个项目中,您需要将第二个控件放在第一个堆栈面板中。

<toolkit:Accordion Canvas.Left="480" Canvas.Top="104" Height="100" Name="accordion1" Width="300">
<toolkit:AccordionItem Header="A">
     <StackPanel>
          <local:AddRemoveControl x:Name="AddRemoveAgents" Margin="470,90,0,0">                                        
      </local:AddRemoveControl>
          <local:DatesFilter x:Name="DatesFilter" Margin="475,200,0,0" Canvas.Top="76">
          </local:DatesFilter>
     </StackPanel>
 </toolkit:AccordionItem>

You are defining the content twice. Try removing the content tags from the AccordionItem like this:

<toolkit:Accordion Canvas.Left="480" Canvas.Top="104" Height="100" Name="accordion1" Width="300">
    <toolkit:AccordionItem Header="A">
            <StackPanel>
                <local:AddRemoveControl x:Name="AddRemoveAgents" Margin="470,90,0,0"></local:AddRemoveControl>
            </StackPanel>
        </toolkit:AccordionItem>
    <toolkit:AccordionItem Header="B -  long header">
            <StackPanel>
                <local:DatesFilter x:Name="DatesFilter" Margin="475,200,0,0" Canvas.Top="76"></local:DatesFilter>
            </StackPanel>
    </toolkit:AccordionItem>
</toolkit:Accordion>

Also, the way you have it currently you will end up with two Accodion items with one control in each. To get both the controls in the same item you need to put the second control in the first stackpanel.

<toolkit:Accordion Canvas.Left="480" Canvas.Top="104" Height="100" Name="accordion1" Width="300">
<toolkit:AccordionItem Header="A">
     <StackPanel>
          <local:AddRemoveControl x:Name="AddRemoveAgents" Margin="470,90,0,0">                                        
      </local:AddRemoveControl>
          <local:DatesFilter x:Name="DatesFilter" Margin="475,200,0,0" Canvas.Top="76">
          </local:DatesFilter>
     </StackPanel>
 </toolkit:AccordionItem>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文