关于UWP数据绑定的一个坑 x:bind修改为binding

<Page
    x:Class="AlbumCoverMatchGame.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:AlbumCoverMatchGame"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    xmlns:data="using:AlbumCoverMatchGame.Models">

    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <Grid.RowDefinitions>
            <RowDefinition Height="100"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <StackPanel Grid.Row="0">
            <ProgressBar Name="myProressBar" Maximum="100" Minimum="0" Value="100" Height="20" Foreground="blue"/>
            <TextBlock Name="InstructionTextBlock" Text="" Foreground="Blue" HorizontalAlignment="Center"/>
            <MediaElement Name="MyMediaElement" AutoPlay="True"/>
        </StackPanel>
        <StackPanel Grid.Row="1" Orientation="Vertical">
            <GridView Name="SongGridView"
                      ItemsSource="{Binding Songs}"
                      IsItemClickEnabled="True"
                      ItemClick="SongGridView_OnItemClick">
                <GridView.ItemTemplate>
                    <DataTemplate>
                        <Grid>
                            <Image Name="AlbumArtImage"
                      Height="70"
                      Width="75"
                      Source="{Binding AlbumCover}"/>  <!--这里的x:bind修改为Binding识别属性值  这是一个坑请注意<StackPanel Grid.Row="1" Orientation="Vertical">
            <GridView Name="SongGridView"
                      ItemsSource="{Binding Songs}"
                      IsItemClickEnabled="True"
                      ItemClick="SongGridView_OnItemClick">
                <GridView.ItemTemplate>
                    <DataTemplate x:DataType="data:Song">
                        <Grid>
                            <Image Name="AlbumArtImage"
                      Height="70"
                      Width="75"
                      Source="{x:Bind AlbumCover}"/>
                        </Grid>
                    </DataTemplate>
                </GridView.ItemTemplate>
            </GridView> 这里也可以这么写-->
                        </Grid>
                    </DataTemplate>
                </GridView.ItemTemplate>
            </GridView>

        </StackPanel>
        <Button Click="ButtonBase_OnClick" Content="Click Me"/>
    </Grid>
</Page>

 

 

 

posted @ 2017-07-26 20:04  拿破仑波拿巴  阅读(92)  评论(0编辑  收藏  举报