WPF 绑定(bind) : Waiting for ItemsSource

标签 wpf data-binding mvvm binding

我对以下绑定(bind)有疑问:

<telerik:RadComboBox ItemsSource="{Binding Source={StaticResource TemplateDataSource}, Path=Templates}"
                     SelectedValue="{Binding Template}"
                     SelectedValuePath="Id"
                     DisplayMemberPath="Title"
                     Margin="0">
</telerik:RadComboBox>

我所有的数据都是通过 WCF 数据服务异步加载的。

有时我会收到以下错误(我可以追溯到上面的绑定(bind))
Specified argument was out of the range of valid values.
Parameter name: index

现在我猜它与提供在 ItemsSource 之前加载的 SelectedValue(模板)的实体有关。这可能吗?是否有解决此问题的方法,例如等待 ItemsSource 加载?

提前感谢您的帮助!

最佳答案

尝试在 SelectedValue="{Binding Template}" 上编写虚拟转换器
然后,您可以调试此转换器以找出错误的真正原因。

关于WPF 绑定(bind) : Waiting for ItemsSource,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7050254/

相关文章:

c# - 如何在 Repeater 中设置 DropDownList 选定值?

Javascript数据将元素属性绑定(bind)到URL中的 anchor href

wpf - 在 "old"DataContext 中调用 RelayCommand

c# - 将按键事件绑定(bind)到 WPF 中的 ListViewItem

javascript - AJAX Web 开发的最佳技术

wpf - VS2012 - 将 WPF 现有用户控件添加到项目

.net - 无法在通用 Windows 或 WPF 应用程序中引用 .NET Core 类库

.net - 在 Windows 应用程序中格式化标签内的文本

silverlight - Silverlight 的 BindingBase.Delay

安卓数据绑定(bind): Observable List to RecyclerView's Adapter