0
我似乎无法使用我的组合框过滤我的列表框,尽管文本过滤器正常工作。如何解决无法将字符串转换为类别的问题?无法将字符串转换为类别错误
部分:StaffListView.xaml
StaffController sc = (StaffController)Application.Current.FindResource("staffcontroller");
public StaffListView()
{
InitializeComponent();
StaffController sc = (StaffController)Application.Current.FindResource("staffcontroller");
}
private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (e.RemovedItems.Count > 0)
{
//too much going on i think it sees the() as a method because of the ToString
sc.FilterBy(comboBox.SelectedItem.ToString());
//MessageBox.Show("Dropdown list used to select: " + e.AddedItems[0]);
}
}
StaffControler的部分:
public void FilterBy(Category currCategoryFilter)
{
var selected = from Staff s in MasterStaffListBasic
where currCategoryFilter == Category.All || s.StaffCategory == currCategoryFilter
select s;
ViewableStaffList.Clear();
selected.ToList().ForEach(ViewableStaffList.Add);
}
编辑: 也只是为了澄清类别是控制器
不要破坏你的帖子。 – dorukayhan