ページに50個のボタンがあるので、すべてのボタンに適用される境界線とIsPressed動作を宣言するStyleを宣言しました。WPF Button ...スタイル宣言とは別に背景色を設定する方法はありますか?
<UserControl.Resources>
<statusModule:BooleanToBackgroundColorConverter x:Key="BooleanToBackgroundColor"/>
<Style x:Key="ValveButtonStyle" TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Name="border" Background="Transparent" BorderThickness="1" BorderBrush="Black">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="Button.IsPressed" Value="True">
<Setter TargetName="border" Property="BorderThickness" Value="3" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
私が持っている問題は、各ボタンの背景色は、
<Button Content="Deflection Gas Valve" Background="{Binding Path=OpenDeflectionGasValve, Converter={StaticResource BooleanToBackgroundColor}, Mode=OneWay}" Style="{StaticResource ValveButtonStyle}"
<Button Content="Purge Gas Valve" Background="{Binding Path=OpenPurgeGasValve, Converter={StaticResource BooleanToBackgroundColor}, Mode=OneWay}" Style="{StaticResource ValveButtonStyle}"
と完全に異なるビューモデルプロパティになるであろう結合別のボタンの背景として、別々のビューモデルのプロパティを介して制御されることです。
ボタンにスタイルを割り当てると、上記で宣言した背景設定は効果がありません。
すべてのボタンにスタイルを使用できますが、上記のようにバックグラウンドの値を宣言する方法はありますか?
は助けるために言及したスタイルを貼り付け! –