0

我正在尝试使用 a 但出现错误:属性“内容”设置不止一次。如果我删除标签之间的两行代码中的任何一行,它就会消失。因此,它们似乎都不是单独的错误,但两者共同导致了问题。

<Grid x:Name="LayoutRoot" Background="Transparent">

    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>

    <!--TitlePanel contains the name of the application and page title-->
    <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
        <TextBlock x:Name="ApplicationTitle" Text="New Trip" Style="{StaticResource PhoneTextNormalStyle}" Height="40" />
        <Button Content="Back" Height="71" Name="button1" Width="103" HorizontalContentAlignment="Stretch" VerticalAlignment="Top" HorizontalAlignment="Right" Click="button1_Click" />
    </StackPanel>

    <!--ContentPanel - place additional content here-->
    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
        <ScrollViewer>
            <TextBlock Height="60" HorizontalAlignment="Left" Margin="65,12,0,0" Name="textBlock1" Text="Username" VerticalAlignment="Top" Width="169" />
            <TextBox Height="78" HorizontalAlignment="Left" Margin="60,60,0,0" Name="textBoxUsername"  VerticalAlignment="Top" Width="274"  />
        </ScrollViewer>
    </Grid>

</Grid>
4

2 回答 2

3

ScrollViewer 只能有 1 个内容,因此将 ScrollViewer 内的控件包装在 Grid、DockPanel、StackPanel 等容器中

      <ScrollViewer>
        <StackPanel>
            <TextBlock Height="60" HorizontalAlignment="Left" Margin="65,12,0,0" Name="textBlock1" Text="Username" VerticalAlignment="Top" Width="169" />
            <TextBox Height="78" HorizontalAlignment="Left" Margin="60,60,0,0" Name="textBoxUsername"  VerticalAlignment="Top" Width="274"  />
        </StackPanel>
      </ScrollViewer>
于 2012-04-13T13:54:37.137 回答
0

将您的<TextBlock>and<TextBox>放在另一个容器中,例如 StackPanel。

于 2012-04-13T13:51:48.963 回答