C# 交叉装订复选框-已选中#1->;我无法找到#2

C# 交叉装订复选框-已选中#1->;我无法找到#2,c#,xaml,binding,C#,Xaml,Binding,我有一个列表框,它从模型中的列表中获取布尔元素,并将它们表示为复选框。在构建项目之后,第二个复选框isEnabled设置为false。如果我在调试中的第二个复选框中修改(例如,剪切并粘贴相同的转换器)绑定,绑定将开始正常工作。此外,我还有一个全局复选框,modyfi可以检查列表框中所有复选框的属性。如果我将globalCheckbox#2设置为true,则所有listBox#U复选框#2都将设置为true,所有listBox#U复选框#1 isEnabled属性都将设置为false XAML:

我有一个列表框,它从模型中的列表中获取布尔元素,并将它们表示为复选框。在构建项目之后,第二个复选框isEnabled设置为false。如果我在调试中的第二个复选框中修改(例如,剪切并粘贴相同的转换器)绑定,绑定将开始正常工作。此外,我还有一个全局复选框,modyfi可以检查列表框中所有复选框的属性。如果我将globalCheckbox#2设置为true,则所有listBox#U复选框#2都将设置为true,所有listBox#U复选框#1 isEnabled属性都将设置为false

XAML:


如何修复绑定以在构建之后获得完整的功能?

我找到了解决方案。xaml中的DataTrigger被isEnabled属性覆盖

<ListBox x:Name="ListBox_assent" SelectedIndex="-1" Grid.Row="2" ItemsSource="{Binding Path=FullDataAssetList.List}" IsSynchronizedWithCurrentItem="True" Height="Auto">
<ListBox.ItemContainerStyle>
    <Style TargetType="{x:Type ListBoxItem}" BasedOn="{StaticResource MaterialDesignListBoxItem}">
        <Setter Property="Margin" Value="2"/>
        <Setter Property="HorizontalAlignment" Value="Left"/>
        <Setter Property="Focusable" Value="False" />
        <EventSetter Event="RequestBringIntoView" Handler="ListBoxItem_RequestBringIntoView"/>
    </Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemTemplate>
    <DataTemplate>
        <StackPanel Grid.Row="0" Opacity="{Binding Path=SkipAssentTemp, Converter={StaticResource BoolToOpacity}}">
            <StackPanel Orientation="Horizontal" Grid.Row="0" Grid.Column="3">
                <CheckBox  x:Name="chbx_Assent" HorizontalContentAlignment="Left" FlowDirection="RightToLeft" ToolTip="Skip" IsChecked="{Binding SkipAssent, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsEnabled="{Binding SkipAssentTemp, Converter={StaticResource InverseBoolean}}" LostFocus="chbx_Assent_LostFocus" Background="#FFCB0000"/>
                <TextBlock FontSize="16" Text=" / "  VerticalAlignment="Center"/>
                <CheckBox x:Name="chbx_AssentTemp" HorizontalContentAlignment="Left" FlowDirection="RightToLeft" ToolTip="Skip temp." IsChecked="{Binding SkipAssentTemp, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"  IsEnabled="{Binding SkipAssent, Converter={StaticResource InverseBoolean}}" LostFocus="chbx_AssentTemp_LostFocus" Background="#FFCBA300"/>
            </StackPanel>
        </StackPanel>
    </DataTemplate>
</ListBox.ItemTemplate>
public class InverseBooleanConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        if (targetType == typeof(bool) || targetType == typeof(bool?))
        {
            if ((bool?)value == true)
            {
                return false;
            }
            else
            if ((bool?)value == false)
            {
                return true;
            }
            return null;

        }
        else
        {
            throw new InvalidOperationException("The target must be a boolean");
        }
    }

    public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        throw new NotSupportedException();
    }

 }