简体   繁体   English

C#Windows Phone 8.1特定于Listview的导航

[英]C# Windows Phone 8.1 specific Navigation in Listview

Hello i'm new in programming and i making a Football Windows Phone 8.1 Application using Web Services. 您好,我是编程新手,我使用Web服务制作了Football Windows Phone 8.1应用程序。 i created a class Football.cs: 我创建了一个Football.cs类:

    public int Id { get; set; }
    public string Team1 { get; set; }
    public string Team2 { get; set; }
    public string Score { get; set; }
    public string Place { get; set; }
    public string Stadium { get; set; }

Then i generated a Web API 2 Controller using Entity Framework to create the DataBase and get the data from it. 然后,我使用实体框架生成了一个Web API 2控制器,以创建数据库并从中获取数据。 Then i created a Windows Phone application, in the Mainpage.xaml here's the code : 然后我在Mainpage.xaml中创建了一个Windows Phone应用程序,代码如下:

<Page.Resources>
    <DataTemplate x:Key="EmployeeDataTemplate">
        <Grid Margin="12,12,12,0"
            Width="376">
            <TextBlock 
                FontSize="24" 
                Text="{Binding Team1}"/>
            <TextBlock 
                FontSize="24"
                HorizontalAlignment="Right" 
                Text="{Binding Team2}"/>
            <StackPanel>
                <TextBlock 
                    FontSize="18.667"
                    HorizontalAlignment="Center"
                    Text="{Binding Score}" />
            </StackPanel>
        </Grid>
    </DataTemplate>
</Page.Resources>

<Page.DataContext>
    <Core:MainViewModel/>
</Page.DataContext>

<Grid>
    <ListView x:Name="mainListView"
              ItemsSource="{Binding EmployeesList}"
              ItemTemplate="{StaticResource EmployeeDataTemplate}" 
              IsItemClickEnabled="True" 
              ItemClick="listView_ItemClick"/>
</Grid>

then i created a new BasicPage.xaml: 然后我创建了一个新的BasicPage.xaml:

<Page.DataContext>
    <Core:MainViewModel/>
</Page.DataContext>

<StackPanel>
    <TextBlock Text="{Binding Place}" />
    <TextBlock Text="{Binding Stadium}"/>
</StackPanel>

Can you help me please, i'm a beginner and i tried to make it but without success. 你能帮我吗,我是一个初学者,我试图做到但没有成功。 All i want is when i click in a specific Item in the ListView, the Basic Page will display the Place and the Stadium to ONLY and ONLY to this specific Item , not the first one and not all of them. 我想要的只是当我在ListView中单击特定项目时,“基本页面”将仅显示和仅显示该特定项目的地方和体育场,而不是第一个,不是全部。 Thank you very much, i appreciate it 非常感谢你,我很感激

See my answer here , I use the Behaviours Sdk(how to add) in conjunction with a custom converter class to receive the tapped item in the list. 在这里查看我的答案,我将Behaviors Sdk(如何添加)与自定义转换器类结合使用以接收列表中被点击的项目。 I believe this is what you are looking for. 我相信这就是您要寻找的。

If you are using MVVM Light you can do this with generic RelayCommand<T> like this: 如果您使用的是MVVM Light,则可以使用通用的RelayCommand<T>来执行此操作,如下所示:

<ListView x:Name="mainListView"
          ItemsSource="{Binding EmployeesList}"
          ItemTemplate="{StaticResource EmployeeDataTemplate}" 
          IsItemClickEnabled="True" 
          Command={Binding ShowMathInfo, Source={StaticResource MainViewModel}}"
          CommandParameter="{Binding }"/>

Then in your command execute method you will get item what you clicked on, then you will be able to pass this item to another page or what you need to do with it. 然后,在您的命令执行方法中,您将获得单击的项目,然后就可以将该项目传递给另一页或您需要执行的操作。

there's no propertie called Command under ListView. ListView下没有称为Command的属性。 or maybe it's not like this ? 还是不是这样? am i wrong ? 我错了吗 ? sorry but i'm a really beginner 对不起,但我是一个真正的初学者

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM