【问题标题】:How can I debug the binding of my ViewModels to my View?如何调试 ViewModel 与 View 的绑定?
【发布时间】:2010-11-10 02:57:49
【问题描述】:

我的视图中有这个 ItemsControl:

<ItemsControl 
    ItemsSource="{Binding ItemPageItemViewModels}"
    ItemTemplate="{StaticResource ItemPageItemViewModelsTemplate}"/>

在它上面我有这个渲染所有项目的 DataTemplate:

<DataTemplate x:Key="ItemPageItemViewModelsTemplate">
    <TextBlock Text="{Binding Title}"/>
</DataTemplate>

问题是,虽然我的 ViewModel 中的 ItemPageItemViewModels ObservableCollection 中有 8 个对象,但只有 last 对象被在屏幕上显示 8 次

我可以在我的 ViewModel 中设置一个断点来查看 ObserverableCollection 中确实有 8 个不同的对象,但是我如何调试绑定来查看为什么这个 DataTemplate 会呈现最后一个集合中的对象在我的屏幕上出现 8 次?

【问题讨论】:

标签: wpf debugging mvvm binding observablecollection


【解决方案1】:

请参阅 Bea Stollnitz 的精彩文章。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-12-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-26
    • 2012-03-18
    • 1970-01-01
    相关资源
    最近更新 更多