在我当前应用程序的几个点上,我有一个ItemTemplate,如下所示:
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<ToggleButton Margin="2,0" Content="{Binding}" Tag="{Binding}" Click="ToggleButton_Click">
<ToggleButton.IsChecked>
<MultiBinding Mode="OneWay" Converter="{StaticResource EqualityConverter}">
<Binding RelativeSource="{RelativeSource Self}" Path="Tag">
</Binding>
<Binding RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type cc:ToggleButtonPanel}}" Path="SelectedItem">
</Binding>
</MultiBinding>
</ToggleButton.IsChecked>
</ToggleButton>
</DataTemplate>
</ItemsControl.ItemTemplate>
现在,我已逐步完成了转换器,并按预期返回true
和false
,但控件未更改其ischecked
状态...有没有绑定错误,这只有在使用 ItemsTemplate / DataTemplate组合时才会发生。还有其他人看到过这种行为吗?