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

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

问题描述

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

I am having the following XAML code, which throws error following error pointing to line# 16.

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

the property 'Content' is set more than once

有什么想法吗?

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>

推荐答案

Content 属性通常映射到 之间的任何内容代码>标签,例如

The Content property is normally mapped to whatever is between the <X> and </X> tags, e.g.

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

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

But it can also be set like a normal property, e.g.

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

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

In your example you are doing both by setting the Content property on line 15 like a normal property and again on line 16 between the tags. I'm guessing you will want to get rid of the Content="Viewer" on line 15 to get the output you are looking for.

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

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