2012-03-15 67 views
0

我有按钮作为项目控件的项目。可以检查按钮,一旦它被点击,它将显示突出显示,直到再次点击(具有缺陷性质)。我的问题是我需要使这个按钮检查互斥?在任何时候,我只想让一个按钮突出显示。我使用的itemscontrol,因为我可以包装的按钮,以便它将水平填充直到分配的宽度,并将继续下一行。项目控件中的互斥按钮

下面

<ItemsControl ItemsSource="{Binding Path=NewItemsList,ElementName=newitemcontrol}">    
      <ItemsControl.ItemsPanel> 
       <ItemsPanelTemplate>      
        <WrapPanel Orientation="Horizontal" >      
         </WrapPanel> 
        </ItemsPanelTemplate> 
       </ItemsControl.ItemsPanel>    
       <ItemsControl.ItemTemplate> 
        <DataTemplate> 
          <dc:ButtonDropDown Name="SubItems" Width="120" 
        Height="120" ItemsSource="{Binding Path=DataContext.Children, RelativeSource={RelativeSource Mode=Self}}" Header="{Binding Path=DataContext.DisplayName, RelativeSource={RelativeSource Mode=Self}}" Command="{Binding Path=ChangeSubItem, ElementName=newitemcontrol}" CommandParameter="{Binding DataContext, RelativeSource={RelativeSource Mode=Self}}"  ImageSource="{Binding Path=DataContext.ImageUri, RelativeSource={RelativeSource Mode=Self}}" ImagePosition="Top"   IsCheckable="True" >       


          </dc:ButtonDropDown> 
        </DataTemplate> 
        </ItemsControl.ItemTemplate> 
        </ItemsControl> 
+0

尝试切换按钮 – Phil 2012-03-15 17:49:13

+4

您可以使用GroupName属性通过RadioButton执行此操作。我不知道关于dc:ButtonDropDown – 2012-03-15 17:49:55

+0

也可以,如果项目是静态元素,您可能想使用'Panel'(而不是'ItemsControl') – 2012-03-15 18:46:52

回答

0

的XAML谢谢您的答复。我需要在容器内使用dropdownbutton(我知道radiobutton)。我解决这个问题的方式是使用listbox而不是itemscontrol。列表框应该是单选,并将下拉按钮缺省属性绑定到其listboxitem的isSelected属性。