0

ラジオ Button を備えた 1 つのデータ グリッドを持つ 1 つのビューがあり、ラジオ ボックスをオンにすると、選択した行は他のビュー画面のテキスト ボックスに移動する必要があります

これが私の最初のViewModelです

public class CampaignSearchResultsViewModel : ViewModelBase
    {

        public CampaignSearchResultsViewModel(List<Lead> obj)
        {
            foreach(Lead lead in obj)
            {
                SelectedLead = lead;
            }
        }

        public CampaignSearchResultsViewModel()
        {

            this.Commands.Add("CheckedCommand", new ActionCommand<Lead>(CheckIt));

            Commands.Add("OutboundSelect", new ActionCommand<Object>(OutboundSelection));

            _leads = new ObservableCollection<Lead>();

        }

        public ICommand OutboundSelect
        {
            get
            {
                return Commands["OutboundSelect"];
            }
        }

        public void OutboundSelection(Object obj)
        {


        }

        private void CheckIt(Lead lead)
        {

            SelectedLead = lead;
            LeadViewModel lmv = new LeadViewModel(this);

        }



        #region Private
        private ObservableCollection<Lead> _leads;

        public bool IsChecked { get; set; }

        private ICommand _checkedCommand;
        private object _testProperty;

        private Lead _selectedLead;

        private ICollectionView icv;

        #endregion

        private ICommand _checkedRadioCommand;
        private bool _inboundChecked;


        #region Properties
        public ObservableCollection<Lead> Leads
        {
            get { return _leads; }
            set
            {
                _leads = value;
                FirePropertyChanged("Leads");
            }
        }

        public Lead SelectedLead
        {
            get { return _selectedLead; }
            set { _selectedLead = value; }
        }

        public ICommand CheckedCommand
        {
            get
            {
                return Commands["CheckedCommand"];
            }
        }

        public bool InboundChecked
        {
            get
            {
                return _inboundChecked;
            }
            private set
            {
                if (_inboundChecked != value)
                {
                    _inboundChecked = value;
                    FirePropertyChanged("InboundChecked");
                }
            }
        }

        #endregion
    }

SelectedLead を他のビュー モデルにマップする必要があります。 SearchCampaignMembers() メソッドに情報を渡します。

 public partial class LeadViewModel : ViewModelBase
 {

       public void SearchCampaignMembers()
        {
            _service.Load(_service.SearchCampaignMembersQuery(Entity.FirstName, Entity.LastName), lo =>
            {
                if (!lo.HasError)
                {

                    ListLead = lo.Entities.ToList();

                    _savedLeadStatusId = Entity.LeadStatusId;

                    EntitySet = _service.Leads;


                    if (ListLead.Count == 1)
                    {
                        if (Entity != null)
                        {
                            IsVendorLead = Entity.LeadTypeId == Lookups.LeadType.VendorLead;

                            //Lead Update History
                            EntityQuery<LeadUpdateHistory> historyquery = null;
                            historyquery = _service.GetLeadUpdateHistoryByLeadIdQuery(Entity.LeadId);
                            _service.Load(historyquery, l =>
                            {
                                if (!l.HasError)
                                {
                                    EntityHistory = _service.LeadUpdateHistories;
                                }
                            }, null);

                            //Lead Assignment
                            EntityQuery<LeadsAssignment> assignmentquery = null;
                            assignmentquery = _service.GetLeadsAssignmentByLeadIdQuery(Entity.LeadId);
                            _service.Load(assignmentquery, l =>
                            {
                                if (!l.HasError)
                                {
                                    EntityAssignment = _service.LeadsAssignments;
                                }
                            }, null);

                            if (Entity.LeadTypeId == Lookups.LeadType.PhoneLead)
                            {
                                IsInboundLead = Entity.VendorId == null;
                                IsOutboundLead = Entity.VendorId != null;
                            }
                            else
                            {
                                IsInboundLead = false;
                                IsOutboundLead = false;
                            }

                            //SelectTimeToCall(Entity);

                            if (IsOutboundLead)
                                SelectedCampaign = Entity.LeadCampaigns.FirstOrDefault().Campaign;
                            else
                                SelectCampaign(Entity);

                            OperationsListener listener = new OperationsListener();

                            listener.Completed += (s, args) =>
                            {
                                CompleteInitializing();
                                //SwitchTab(param.InitialTab);

                                Action action = () =>
                                {
                                    SelectDealer(Entity);
                                };
                                //GetDealerRecommendation(Entity.Address.ZipCode, action);

                                SelectStatus(Entity);

                                //if (callback != null)
                                //    callback();
                            };
                            LoadLookupData(listener);
                            listener.Start();
                        }
                    }
                    else if (ListLead.Count >= 1)
                    {
                        CampaignSearchResultsViewModel vm = new CampaignSearchResultsViewModel();
                        foreach (Lead lead in ListLead)
                        {
                            vm.Leads.Add(lead);
                            ObservableCollection<Lead> abc;
                            abc = new ObservableCollection<Server.DataAccess.Lead>();

                        }
                        ViewController.OpenDialog("SearchCampaignResults", vm, r =>
                        {

                        });

                    }
                    else if (ListLead.Count == 0)
                    {
                        ViewController.OpenDialog("NoResults", (r) =>
                        {

                        });

                    }
                }
                else
                {
                    //if (callback != null)
                    //    callback();
                }
            }, null);

        }

 }
4

1 に答える 1

0

MVVM Light Toolkitを使用する場合は、Messengerclassを参照してください。サンプルについては、この回答を参照してください

于 2013-06-10T14:04:37.020 に答える