ItemTemplate + DataTemplate是否模糊了绑定?

时间:2009-08-31 15:06:39

标签: wpf templates binding

在我当前应用程序的几个点上,我有一个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>

现在,我已逐步完成了转换器,并按预期返回truefalse,但控件未更改其ischecked状态...有没有绑定错误,这只有在使用 ItemsTemplate / DataTemplate组合时才会发生。还有其他人看到过这种行为吗?

0 个答案:

没有答案