【问题标题】:the property content is set more than once属性内容被多次设置
【发布时间】:2011-12-26 22:59:21
【问题描述】:

我的代码如下所示。

错误:

属性“内容”设置了多次

代码:

<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>

【问题讨论】:

    标签: xaml windows-phone-7


    【解决方案1】:

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

    <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>
    

    【讨论】:

    • 这让我难过了这么久
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多