属性'Content'被设置了多次

9

我有以下的XAML代码,执行时会报错并指向第16行。

属性 'Content' 被设置了多次

你有什么想法吗?

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>
2个回答

8

Content属性通常被映射到位于<X></X>标签之间的任何内容,例如:

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

但它也可以像普通属性一样设置,例如:
<Control Content="This stuff is set to the Content property" />

在您的示例中,您通过在第15行设置Content属性(像普通属性一样)以及在标签之间再次设置Content属性(第16行)来执行这两个操作。我猜想您会想要删除第15行的Content="Viewer",以获得您所期望的输出结果。


2

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


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接