【发布时间】:2017-05-04 08:51:58
【问题描述】:
我正在 Visual Studios 2015 中构建一个 wpf 应用程序,我是 Visual Studios 和 C# 的新手,遇到了一个小问题。
我有一个函数(如下所示)。在 SelectionChanged 事件中,我获取 ClientList 的值并将其设置为局部变量 client。
public void ClientList_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
short client = (short)ClientList.SelectedValue;
foreach (var orgComm in orgComms)
{
if(orgComm.OrgId == client)
{
CommList.ItemsSource = orgComm.CommunicationTemplateConfigs;
CommList.SelectedIndex = 0;
}
}
}
我需要这个简短的局部变量对应用程序中的其他函数公开可用,尽管这听起来很简单,但答案似乎一直在逃避我。
【问题讨论】:
-
在方法外创建公共属性
-
为什么这个问题用 wpf 标记?
标签: c# wpf variables local short