2

我正在浏览Windows 8 必应翻译演练

除了 XAML 部分,我能够关注所有内容。我对 XAML 很陌生。以下是演练建议的内容,但是 VS2012 指示标记无效,并且显示的错误显示“属性“内容”设置了多次”。这是唯一的问题吗?哪里设置了不止一次?

<GridView ItemTemplate="{StaticResource TweetTemplate}" SelectionMode="None" ItemsSource="{Binding tweets}"></GridView> 
<DataTemplate x:Key="TweetTemplate">
        <Grid>
            <Rectangle Fill="#FFDA713F" HorizontalAlignment="Left" Height="115" Margin="10,11,0,0" 
         VerticalAlignment="Top" Width="455" RadiusX="20" RadiusY="20"/>
        <TextBlock Foreground="White" HorizontalAlignment="Left" Height="50" 
            Margin="176,12,0,0" TextWrapping="Wrap" x:Name="txtTweet" 
            Text="{Binding Title}" VerticalAlignment="Top" Width="277" FontSize="12"/>
        <TextBlock Foreground="White" HorizontalAlignment="Left" Height="50" 
            Margin="176,72,0,0" TextWrapping="Wrap" x:Name="txtTrans" 
            Text="{Binding translatedText}" VerticalAlignment="Top" Width="277" 
             FontSize="12"/>
        <Image Source="{Binding ImageUri}" HorizontalAlignment="Left" Height="89" 
            Margin="20,20,0,0" VerticalAlignment="Top" Width="116"/>
        <TextBlock Foreground="White" HorizontalAlignment="Left" Height="17" 
             Margin="24,109,0,0" TextWrapping="Wrap" Text="{Binding Author}" 
            VerticalAlignment="Top" Width="150" FontSize="10"/>

        </Grid>
        </DataTemplate>
4

1 回答 1

2

...我一发布问题,我就找到了答案。以上需要安排如下:请注意,从上面提供的链接中的示例中,作者使用了 RefreshAppBarButtonStyle。这已更改为 AppBarButtonStyle。我不确定我是否完全理解 xaml 页面,但至少我有一个可以诊断的工作框架。

<Page.Resources>
    <DataTemplate x:Key="TweetTemplate">
        <Grid>
            <Rectangle Fill="#FFDA713F" HorizontalAlignment="Left" Height="115" Margin="10,11,0,0" VerticalAlignment="Top" Width="455" RadiusX="20" RadiusY="20"/>
            <TextBlock Foreground="White" HorizontalAlignment="Left" Height="50" Margin="176,12,0,0" TextWrapping="Wrap" x:Name="txtTweet" Text="{Binding Title}" VerticalAlignment="Top" Width="277" FontSize="12"/>
            <TextBlock Foreground="White" HorizontalAlignment="Left" Height="50" Margin="176,72,0,0" TextWrapping="Wrap" x:Name="txtTrans" Text="{Binding translatedText}" VerticalAlignment="Top" Width="277" FontSize="12"/>
            <Image Source="{Binding ImageUri}" HorizontalAlignment="Left" Height="89" Margin="20,20,0,0" VerticalAlignment="Top" Width="116"/>
            <TextBlock Foreground="White" HorizontalAlignment="Left" Height="17" Margin="24,109,0,0" TextWrapping="Wrap" Text="{Binding Author}" VerticalAlignment="Top" Width="150" FontSize="10"/>

        </Grid>
    </DataTemplate>
</Page.Resources>
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
    <GridView ItemTemplate="{StaticResource TweetTemplate}" SelectionMode="None" ItemsSource="{Binding tweets}"></GridView>
</Grid>
<Page.BottomAppBar>
    <AppBar x:Name="bottomAppBar" Padding="10,0,10,0">
        <Grid>
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
                <TextBlock x:Name="txtPrompt" Text="Search Term:  " Height="24" FontSize="24"></TextBlock>
                <TextBox x:Name="txtSearchTerm" Width="300" Height="24"></TextBox>
                <Button Style="{StaticResource AppBarButtonStyle}" Click="Button_Click_1"  />
            </StackPanel>
        </Grid>
    </AppBar>
</Page.BottomAppBar>

希望这对其他人也有用。

保罗

于 2013-01-14T02:21:12.037 回答