了解动作和UriQuery

时间:2013-03-01 15:54:13

标签: c# wpf mvvm

我在工作中得到了一项任务,作为一名实习生,一切都是新的哈哈。我被要求做以下事情:

//To test this you will need to update the code CoreModuleDesktop.cs.
this.NavManager.RegisterCommonActionItem("History Audit Log", "AuditLog", 110,
                    new BitmapImage(new Uri("pack://application:,,,/Core;component/Resources/maintenance.png")),
                    new Action(() => _regionManager.RequestNavigate(RegionNames.MainRegion, typeof(Views.HistoryAuditLogView).FullName)));

//The part inside the action will need to be changed to look something like this 
//where you specify the parameters.  Then you can pull them out OnNavigateTo method
//like in the ServiceOrderMaintenanceViewModel.  For this step just pass in the 
//Table and Key ID, leave the connection string hard coded.

IRegionManager regionManager = AllianceApp.Container.GetExportedValue<IRegionManager>();
UriQuery query = new UriQuery();

query.Add("AccountID", accountID.ToString());
query.Add("ServiceOrderID", serviceOrderID.ToString());

regionManager.RequestNavigate(RegionNames.MainRegion, new Uri(typeof(ServiceOrderMaintenanceView).FullName + query.ToString(), UriKind.Relative));

它们对Action内部的含义是什么?世界上的查询是如何提供的。任何帮助将不胜感激!

1 个答案:

答案 0 :(得分:1)

“操作内部”是<here>

new Action(() => <here> );

为了在Action中放置多行,您需要使用花括号{}定义一个块:

new Action(() => 
    {
        // this is
        // a couple of lines
        // of code to modify
    });

希望这可以帮助您入门。有关Action在C#中的工作原理的一些背景,请the msdn documentation