【发布时间】:2014-03-05 17:50:25
【问题描述】:
我的 UI 中有一个绑定到 List<Notification> Notifications { get; set; } 的 ListBox:
<ListBox ItemsSource="{Binding Notifications}"
DisplayMemberPath="ServiceAddress"
Name="NotificationsList"/>
通知有一个与之关联的过滤器标题:
public class Notification
{
public string FilterTitle { get; set; }
public string ServiceAddress { get; set; }
}
我的 UI 有另一个绑定到 List<LogFilter> Filters { get; set; } 的 ListBox:
<ListBox ItemsSource="{Binding Filters}"
DisplayMemberPath="Title"
Name="FiltersList"/>
您可以猜到,LogFilter 包含一个标题:
public class LogFilter
{
public string Title { get; set; }
}
当我在我的 NotificationsList 中选择一个 Notification 时,我希望它根据 Notification 的 FilterTitle 和 LogFilter 的 Title 的映射在我的 FiltersList 中选择相应的 LogFilter。你怎么能通过绑定来做到这一点?
【问题讨论】:
标签: c# .net wpf binding listbox