2011-01-07 27 views
1

这是多余的(每个TextBlock中的Mode=OneTime)?在ItemsSource中设置绑定模式就足够了吗?

  <ListBox ItemsSource="{Binding Path=SearchResultsItems, Mode=OneTime}"> 
       <ListBox.ItemTemplate> 
        <DataTemplate> 
          <StackPanel> 
           <TextBlock Text="{Binding Path=Price, Mode=OneTime}" /> 
           <TextBlock Text="{Binding Path=Description, Mode=OneTime}" /> 
          </StackPanel> 
         </StackPanel> 
        </DataTemplate> 
       </ListBox.ItemTemplate> 
      </ListBox> 

回答

1

我不这么认为。将ItemsSource设置为一次性涉及物品的收集,而不是物品本身。 ItemsSource = OneTime的确表示“如果初始化后项目集合发生更改,请勿更新我的列表框”。

2

我不这么认为。

如果itemssource上的绑定是OneTime模式,当您更改列表(添加或移除项目)时,您不应该获得属性更改,但仍会从列表项的属性中获取属性更改。

因此,如果您不想在商品上显示价格或描述更改,则应在文本块上保留Mode = OneTime。

相关问题