Wpf 为什么所有xaml单选按钮即使在同一组中也被选中?

Wpf 为什么所有xaml单选按钮即使在同一组中也被选中?,wpf,xaml,Wpf,Xaml,在item控件中,我动态绑定了单选按钮列表。具有与视图模型中的“IsChecked”和“Group”绑定的每个单选按钮 在db级别的某些特定场景中,对于同一组中的多个单选按钮,Ischecked将成为true。 在这种情况下,同一组中的所有单选按钮都被选中。当通过绑定检查其他单选按钮时,不会取消选中其他单选按钮 <ItemsControl DataContext="{Binding}" ItemsSource="{Binding TabsList,UpdateSourceTrigger=P

在item控件中,我动态绑定了单选按钮列表。具有与视图模型中的“IsChecked”和“Group”绑定的每个单选按钮

在db级别的某些特定场景中,对于同一组中的多个单选按钮,Ischecked将成为true。 在这种情况下,同一组中的所有单选按钮都被选中。当通过绑定检查其他单选按钮时,不会取消选中其他单选按钮

<ItemsControl DataContext="{Binding}" ItemsSource="{Binding TabsList,UpdateSourceTrigger=PropertyChanged}">
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <ContentControl Margin="5">
                        <RadioButton GroupName="test" IsChecked="{Binding Checked}" Content="{Binding _Header}"></RadioButton>                     
                    </ContentControl >
                </DataTemplate>
            </ItemsControl.ItemTemplate>          
        </ItemsControl>

如果我在绑定后手动检查,它可以正常工作


提前感谢您的回复。

您的问题是由设置
RadioButton
属性的顺序引起的

在这种情况下(与您的情况类似):

而且一切都会正常工作,因为当
被选中时
属性被设置,
单选按钮
已经知道它的组名是什么


我希望它能有所帮助。

否,它仍在检查同一组中的两个单选按钮。我的单选按钮在模板绑定中,它在项目控件中。@BOBINJOSEPH,我根据您编写的信息回答了您的问题。现在,您正在添加更多的详细信息,而不是次要的详细信息。也许你应该在别人回答之前提供,而不是之后。
<RadioButton IsChecked="{Binding IsChecked1}" GroupName="{Binding GroupName}" />
<RadioButton IsChecked="{Binding IsChecked2}" GroupName="{Binding GroupName}" />
<RadioButton GroupName="{Binding GroupName}" IsChecked="{Binding IsChecked1}" />
<RadioButton GroupName="{Binding GroupName}" IsChecked="{Binding IsChecked2}" />