属性内容设置不止一次 [英] the property content is set more than once

查看:24
本文介绍了属性内容设置不止一次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码出现以下错误.

I am getting the following error with my code shown below.

错误:

属性 'Content' 被设置多次

The property 'Content' is set more than once

代码:

<controls:PanoramaItem Header="headlines">
    <TextBlock Text="{Binding Tones}" />
    <ListBox Margin="0,0,-12,0" ItemsSource="{Binding Tones}">
        <ListBox.ItemTemplate>
            <DataTemplate>
                <StackPanel Orientation="Horizontal" Margin="0,0,0,17">
                    <Image Source="{Binding ImageUrl}" Height="75" Width="100"
                        Margin="12,10,9,0" VerticalAlignment="Top"/>
                    <StackPanel Width="311">
                        <TextBlock Text="{Binding Title}" TextWrapping="Wrap"
                            Style="{StaticResource PhoneTextLargeStyle}" />
                    </StackPanel>
                </StackPanel>
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>                
</controls:PanoramaItem>

推荐答案

一个 PanoramaItem 只能有一个子控件,但您当前有一个 TextBlock 和一个 列表框.要解决此问题,只需添加另一个父控件来保存 TextBlock 和 ListBox(例如 StackPanelGrid).例如:

A PanoramaItem can only have one child control but you currently have a TextBlock and a ListBox. To fix this, simply add another parent control to hold the TextBlock and ListBox (such as a StackPanel or a Grid). For example:

<controls:PanoramaItem Header="headlines">
   <grid>
        <TextBlock Text="{Binding Tones}" />
        <!--Double line list with image placeholder and text wrapping-->
        <ListBox Margin="0,0,-12,0" ItemsSource="{Binding Tones}">
            <ListBox.ItemTemplate>
                 <DataTemplate>
                     <StackPanel Orientation="Horizontal" Margin="0,0,0,17">
                         <!--Replace rectangle with image-->
                         <Image Source="{Binding ImageUrl}" Height="75" Width="100" Margin="12,10,9,0" VerticalAlignment="Top"/>
                         <!--<Rectangle Height="100" Width="100" Fill="#FFE5001b" Margin="12,0,9,0"/>-->
                         <StackPanel Width="311">
                              <TextBlock Text="{Binding Title}" TextWrapping="Wrap" Style="{StaticResource PhoneTextLargeStyle}"/>
                              <!--<TextBlock Text="{Binding LineTwo}" TextWrapping="Wrap" Margin="12,-6,12,0" Style="{StaticResource PhoneTextSubtleStyle}"/>-->
                         </StackPanel>
                     </StackPanel>
                  </DataTemplate>
             </ListBox.ItemTemplate>
        </ListBox>               
   </grid> 
</controls:PanoramaItem>

这篇关于属性内容设置不止一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆