我正在尝试减少这种情况:
<CheckBox Content="K1" Grid.Row="0" Grid.Column="0">
<CheckBox.IsChecked>
<local2:BcpBinding Path="RelayOutputMask" Converter="{StaticResource ByteBit2Bool}" ConverterParameters="0,Binding Path=RelayOutputMask" Mode="TwoWay" />
</CheckBox.IsChecked>
</CheckBox>
<CheckBox Content="K2" Grid.Row="0" Grid.Column="1">
<CheckBox.IsChecked >
<local2:BcpBinding Path="RelayOutputMask" Converter="{StaticResource ByteBit2Bool}" ConverterParameters="1,Binding Path=RelayOutputMask" Mode="TwoWay" />
</CheckBox.IsChecked>
</CheckBox>
<CheckBox Content="K3" Grid.Row="0" Grid.Column="2">
<CheckBox.IsChecked >
<local2:BcpBinding Path="RelayOutputMask" Converter="{StaticResource ByteBit2Bool}" ConverterParameters="2,Binding Path=RelayOutputMask" Mode="TwoWay" />
</CheckBox.IsChecked>
</CheckBox>
<CheckBox Content="K4" Grid.Row="0" Grid.Column="3">
<CheckBox.IsChecked >
<local2:BcpBinding Path="RelayOutputMask" Converter="{StaticResource ByteBit2Bool}" ConverterParameters="3,Binding Path=RelayOutputMask" Mode="TwoWay" />
</CheckBox.IsChecked>
</CheckBox>
<CheckBox Content="K5" Grid.Row="0" Grid.Column="4">
<CheckBox.IsChecked >
<local2:BcpBinding Path="RelayOutputMask" Converter="{StaticResource ByteBit2Bool}" ConverterParameters="4,Binding Path=RelayOutputMask" Mode="TwoWay" />
</CheckBox.IsChecked>
</CheckBox>
<CheckBox Content="K6" Grid.Row="0" Grid.Column="5">
<CheckBox.IsChecked >
<local2:BcpBinding Path="RelayOutputMask" Converter="{StaticResource ByteBit2Bool}" ConverterParameters="5,Binding Path=RelayOutputMask" Mode="TwoWay" />
</CheckBox.IsChecked>
</CheckBox>
<CheckBox Content="K7" Grid.Row="0" Grid.Column="6">
<CheckBox.IsChecked >
<local2:BcpBinding Path="RelayOutputMask" Converter="{StaticResource ByteBit2Bool}" ConverterParameters="6,Binding Path=RelayOutputMask" Mode="TwoWay" />
</CheckBox.IsChecked>
</CheckBox>
<CheckBox Content="K8" Grid.Row="0" Grid.Column="7">
<CheckBox.IsChecked >
<local2:BcpBinding Path="RelayOutputMask" Converter="{StaticResource ByteBit2Bool}" ConverterParameters="7,Binding Path=RelayOutputMask" Mode="TwoWay" />
</CheckBox.IsChecked>
</CheckBox>
我试图创建样式并设置“路径”,“转换器”和“模式”属性,但是Visual Studio表示这些不是DependencyProperties
。
有什么想法吗?
编辑:
我意识到我可以删除Grid.Row="0"
。
我正在使用此项目中的ByteBit2Bool转换器: https://www.codeproject.com/Articles/475550/A-bit-of-binding-MVVMing-bytes-bits-based-data