supermsm 2013-12-11 04:13
浏览 898

【初学提问】window phone应用开发的一个关于的绑定问题

我初学window phone的应用开发,现在想实现一个比较的功能,就是点击一个自定义的名字,然后弹出该自定义名字的相关信息,用的绑定的方法,现在遇到的问题是不知道获得绑定的那条的数据。

.cs部分代码如下:

public SetPlayer()
    {
        try
        {
            Players item0 = new Players() { name = "C罗", club = "皇家马德里", ImgUri="PlayerImg/CR.jpg" };
            Players item1 = new Players() { name = "C罗1", club = "皇家马德里21", ImgUri = "PlayerImg/CR.jpg" };
            Players item2 = new Players() { name = "C罗2", club = "皇家马德里2", ImgUri = "PlayerImg/CR.jpg" };
            Players item3 = new Players() { name = "C罗3", club = "皇家马德里3", ImgUri = "PlayerImg/CR.jpg" };
            Players item4 = new Players() { name = "C罗4", club = "皇家马德里4", ImgUri = "PlayerImg/CR.jpg" };
            Players item5 = new Players() { name = "C罗5", club = "皇家马德里5", ImgUri = "PlayerImg/CR.jpg" };
            Players item6 = new Players() { name = "C罗6", club = "皇家马德里6", ImgUri = "PlayerImg/CR.jpg" };

            Alltest.Add(item0);
            Alltest.Add(item1);
            Alltest.Add(item2);
            Alltest.Add(item3);
            Alltest.Add(item4);
            Alltest.Add(item5);
            Alltest.Add(item6);
        }
        catch (Exception e)
        {
            System.Windows.MessageBox.Show("Exception" + e.Message);
        }
    }

xaml部分代码如下:

 <ListBox x:Name="listBox" HorizontalContentAlignment="Stretch" ItemsSource="{Binding Alltest}">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal" Background="Gray" Width="450" Margin="10">
                            <!--绑定Players类的ImgUri属性-->
                            <Image Width="80" Height="80" Source="{Binding ImgUri}" Stretch="Fill" x:Name="ImgPlayers"/>
                            <!--绑定Players类的name属性-->
                            <TextBlock Text="{Binding name }" FontSize="40" Width="150"  x:Name="tblName" />
                            <!--绑定Players类的club属性-->
                            <TextBlock Text="{Binding club}" FontSize="20" Width="280" x:Name="tblClub"/>
                        </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>

应用部分截图如

CSDN移动问答

如我自定义了一个方法,即点击第一条,即显示相关信息,求如何获取绑定的这条信息。

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 对于相关问题的求解与代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作
    • ¥15 求NPF226060磁芯的详细资料