win8中的参数传递

列表页面:

xaml:

Gridview中的数据源是实体的集合:

 <i:EventToCommand Command="{Binding GridViewItemClick_Command}" Event="ItemClick" ></i:EventToCommand>

所以每次点击每个项时,其事件参数为实体,可以通过实体来得到主键。

列表页面的vm:

GridViewItemClick_Command = new RelayCommand<object>(callback =>
            {
                ExCommandParameter para = callback as ExCommandParameter;
                if (null != para)
                {
                    SFModelBase item = (para.EventArgs as ItemClickEventArgs).ClickedItem as SFModelBase;
                    NavigationUtil.GoToPage(this, ApplicationPages.BOOKINFO_VIEW, item.ContentId);
                }
            });

详情页面对应的VM:

public void OnNavigatedTo(Windows.UI.Xaml.Navigation.NavigationEventArgs e)
        {
            if (e.NavigationMode == Windows.UI.Xaml.Navigation.NavigationMode.New)
            {
                string _mContentId = e.Parameter as string;
            }
           
        }

通过页面导航事件来传递参数。

 

posted @ 2013-12-12 19:59  haiziguo  阅读(292)  评论(0编辑  收藏  举报