ComboBox - 无法更改选择/无法选择

时间:2014-04-09 06:15:53

标签: c# xaml combobox

我有一个有组合框的xaml。我有那里的物品,由于某种原因我不能选择它们,当我选择一个项目时,它通常不会让我改变我的选择,如果它只是为了某些值。 这是代码:

<ComboBox SelectedItem="{Binding CurrentUsers}">
    < ComboBox.ItemsSource>
          <MultiBinding Converter="{StaticResource DictionaryKeyToValueConverter"} Mode="OneWay">
               < Binding Path="AllUsersByDepartment"/>
               < Binding Path = " Department"/ >
          < / MultiBinding>
     < / ComboBox.ItemsSource>
     < ComboBox.ItemContainerStyle>
         <Style TargetType = " { x : Type ComboBoxItem}">
              < Setter Property = " IsEnabled">
                   < Setter.Value>
                        <MultiBinding Converter = "{StaticResource DictionaryKeyToValueConverter}" Mode="OneWay " / >
                             <Binding Path = " DataContext.UserToAvailabilityDictionary" RelativeSource ="{RelativeSource Mode=FindAncestor,  AncestorType = { x : Type ComboBox}}"/>
                            < Binding Path = ". "/>
                        < / MultiBinding >
                     < / Setter.Value>
                  </Setter>
             < Style.Triggers >
                 < Trigger Property="IsEnabled " Value = " False " >
                    <Setter Property = " Template">
                        < Setter.Value >
                            < ControlTemplate>
                                < TextBlock Text="{Binding Path=Description}" Foreground="Red"/>
                            < / ControlTemplate>
                        < / Setter.Value>
                      </Setter>
                 < / Trigger>
             < / Style.Triggers
         </Style >
    </ComboBox.ItemContainerStyle >
     < ComboBox.ItemTemplate>
        < DataTemplate>
            < ComboBoxItem Content="{Binding Path=Description}"/>
        < / DataTemplate > 
     </ComboBox.ItemTemplate >
  </ComboBox>

我希望自从将其从计算机复制到手机后,我所写的内容就很明确了。 基本上我有所有用户,我按部门划分。用户只能看到他所在部门的部分,并且可以选择绑定字典可用的部分。如果不可用,ComboBox中的项目将为红色且可选择。这有效。唯一不重要的是改变某些项目的选择,而某些项目不能选择开始(即使它们没有红色,应该是)。我将用户的对象更改为始终在Equals方法中返回false,因为我读到这可能是问题,但它没有帮助。 提前致谢。

更新:我删除了ComboBox项目和模板的样式,我可以选择任何东西。但我真的需要触发器和样式。

1 个答案:

答案 0 :(得分:0)

我删除了ComboBox.ItemTemplate,而是将一个DisplayMemberPath放在ComboBox中,现在它可以正常工作。

相关问题