我正在尝试完成一个 C#/XAML 页面并且遇到了麻烦。基本上,当我尝试编译时,它抱怨变量的名称(Courier_List)在当前上下文中不存在。我从概念上理解为什么它还没有在代码中的任何地方声明。但是,我没有声明它的原因是因为这个打包的 .dll 旨在与一个管理包(XML 文件)一起使用,该管理包(XML 文件)包含该定义(Courier_List)定义为一个列表并包含指示可视编译器放置位置的坐标表格上的清单。
我猜解决方案必须是在表单中声明列表变量......但我不确定如何(以及它是否会工作)只声明变量而不在.dll中的任何地方使用它,那么当一切都是放在一起它将调用管理包中的 Courier_List 并且不会混淆两个同名变量。
我的描述可能会令人困惑,因为很难解释这一点,所以如果有人需要澄清,请告诉我。我已包含以下代码:
[assembly: CLSCompliant(true)]
namespace Flexity.RMA
{
/// <summary>
/// Interaction logic for UserControl1.xaml
/// </summary>
class RMATask : CreateWithLinkHandler
{
public RMATask()
{
try
{
// Sealed Class GUID
this.createClassGuid = new Guid("9ebd95da-1b16-b9ea-274d-6b0c16ce1bf3");
this.classToDelegate = new Dictionary<Guid, CreateLinkHelperCallback>()
{
{ ApplicationConstants.WorkItemTypeId, new CreateLinkHelperCallback (this.WorkItemCallback) }
};
}
catch (Exception exc1)
{
MessageBox.Show(exc1.Message, "Exception", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
public void WorkItemCallback(IDataItem RMAForm, IDataItem IncidentForm)
{
try
{
// Note to self: RelatedWorkItems should be in MP XML as alias under TypeProjections
if (RMAForm != null && RMAForm.HasProperty("RelatedWorkItems"))
{
// Perform Linking
RMAForm["RelatedWorkItems"] = IncidentForm;
// Copy Incident Title to RMA Title
RMAForm["Title"] = IncidentForm["Title"];
// Copy Incident Description to RMA Description
RMAForm["Description"] = IncidentForm["Description"];
// Copy Incident ID to RMA Display Name
RMAForm["DisplayName"] = "From " + IncidentForm["Id"];
}
}
catch (Exception exc2)
{
MessageBox.Show(exc2.Message, "Exception", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
}
public partial class WITemplate: UserControl
{
private readonly RelatedItemsPane _relatedItemsPane;
public WITemplate()
{
InitializeComponent();
var paneConfig = new WorkItemRelatedItemsConfiguration("RelatedWorkItems", "RelatedWorkItemSource",
"RelatedConfigItems", "RelatedKnowledgeArticles",
"FileAttachments");
_relatedItemsPane = new RelatedItemsPane(paneConfig);
tabItemRelItems.Content = _relatedItemsPane;
}
private void Tracking_Button_Click(object sender, RoutedEventArgs e)
{
switch (Courier_List.SelectedValue.ToString())
{
case "UPS":
System.Diagnostics.Process.Start("http://wwwapps.ups.com/ietracking/tracking.cgi?loc=CA_CA^&tracknum^=" + Tracking_Num.Text.ToString());
break;
case "FedEX":
System.Diagnostics.Process.Start("https://www.fedex.com/fedextrack/index.html?tracknumbers^="+Tracking_Num.Text.ToString()+"^&locale=en_CA^&cntry_code=ca_english");
break;
case "UPS SCS":
System.Diagnostics.Process.Start("https://www.upspostsaleslogistics.com/cfw/trackOrder.do?trackNumber^=" + Tracking_Num.Text.ToString());
break;
default:
break;
}
}
}
}