itemscontrol中的互斥按钮

时间:2012-03-15 17:41:18

标签: wpf

我有按钮作为itemscontrol的项目。可以检查按钮,一旦点击它,它将突出显示,直到再次点击(具有缺血属性)。我的问题是我需要让这个按钮检查互斥吗?在任何时候我都希望只有一个按钮可以突出显示。我正在使用itemscontrol,因为我可以包裹按钮,使其水平填满,直到分配的宽度,并继续下一行。

下面的XAML

<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>

1 个答案:

答案 0 :(得分:0)

谢谢你的回复。我需要在容器内使用dropdownbutton(我知道radiobutton)。我解决这个问题的方法是使用listbox而不是itemscontrol。列表框应该是单选,并将dropdownbutton不用的属性绑定到它的listboxitem的isselected属性。

相关问题