【问题标题】:WinRT Combobox strange behaviour in template模板中的 WinRT Combobox 奇怪行为
【发布时间】:2012-07-07 20:26:02
【问题描述】:

在 Win 8 Release Preview 下运行的 WinRT 应用程序中的组合框有一个奇怪的问题。这是一个代码 sn-p :

<ListView.ItemTemplate>
     <DataTemplate>
         <Grid>
              <Grid.ColumnDefinitions>
                  <ColumnDefinition Width="*"/>
                  <ColumnDefinition Width="*"/>
              </Grid.ColumnDefinitions>
              <TextBox Grid.Column="0" Text="{Binding Name, Mode=TwoWay}" VerticalAlignment="Center"/>
              <ComboBox Grid.Column="1" ItemsSource="{Binding Source={StaticResource evtTypeRes}}" SelectedValuePath="ID" DisplayMemberPath="Name" SelectedValue="{Binding EventTypeID, Mode=TwoWay}" VerticalAlignment="Center"/>
          </Grid>
     </DataTemplate>
</ListView.ItemTemplate>

ListView 由 ObservableCollection 列表支持,并且项目实现 INotifyPropertyChanged。问题是,当我更改屏幕中组合框的值时,该值不仅会更改特定行,而且会更改每一行(属性的设置器会在集合中的每个对象上调用)。文本框不是这种情况。这种奇怪行为的原因可能是什么?

提前致谢

【问题讨论】:

  • 如果你解决了你的问题,请发布这个问题的答案(而不是将其编辑到问题本身)。这有助于保持清洁,并从“未回答”列表中删除您的问题。谢谢!

标签: xaml combobox windows-8 microsoft-metro windows-runtime


【解决方案1】:

我发现IsSynchronizedWithCurrentItem 属性的用途:值False 解决了我的问题。

【讨论】:

  • 感谢您将此作为答案发布!现在,如果您接受它(单击答案左侧的复选标记),它将从未回答列表中删除:)
猜你喜欢
  • 1970-01-01
  • 2015-01-14
  • 2011-08-22
  • 2011-08-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-26
  • 1970-01-01
相关资源
最近更新 更多