【问题标题】:the property 'Content' is set more than once属性“内容”设置了多次
【发布时间】:2009-08-25 22:53:17
【问题描述】:

我有以下 XAML 代码,它在指向第 16 行的错误之后引发错误。

属性“内容”设置更多 不止一次

有什么想法吗?

1       <Grid x:Name="LayoutRoot" Width="970" Height="460" Background="White">  
2           <Grid.RowDefinitions>  
3               <RowDefinition Height="*"/>
4               <RowDefinition Height="80"/>
5           </Grid.RowDefinitions>
6           <Border Margin="3" BorderBrush="#FF464646" BorderThickness="1" CornerRadius="5" Grid.Row="0">
7               <Border.Background>
8                   <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
9                       <GradientStop Color="#FF5B5A5A" Offset="0.02"/>
10                      <GradientStop Color="#FF3B3B3B" Offset="0.213"/>
11                      <GradientStop Color="#FF535151" Offset="0.807"/>
12                  </LinearGradientBrush>
13              </Border.Background>
14   
15               <Liquid:Viewer Content="Viewer">
16                   <Image Source="Images/planet.jpg" Opacity="0.8" Stretch="Fill" />
17               </Liquid:Viewer>
18   
19           </Border>
20          <Border Margin="3" BorderThickness="1" CornerRadius="5" Grid.Row="1">
21              <Border.Background>

【问题讨论】:

    标签: silverlight xaml


    【解决方案1】:

    Content 属性通常映射到 &lt;X&gt;&lt;/X&gt; 标记之间的任何内容,例如

    <Control>
        This stuff is set to the Content property
    </Control>
    

    但它也可以像普通属性一样设置,例如

    <Control Content="This stuff is set to the Content property" />
    

    在您的示例中,您通过将第 15 行的 Content 属性设置为普通属性,并再次在标签之间的第 16 行设置 Content 属性。我猜你会想要去掉第 15 行的 Content="Viewer" 以获得你正在寻找的输出。

    【讨论】:

      【解决方案2】:

      在第 15 行中,您在属性中设置内容,在第 16 行中,您将图像设置为 2. 内容。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-05-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多