内部プロパティでトリガーする
<Button BorderBrush="Black" BorderThickness="2" x:Name="TimeButton" ClickMode="Press" Click="SetTime_Click" Height="26" HorizontalAlignment="Left" Margin="15, 0, 0, 0" Style="{StaticResource ImageButtonStyle}" ToolTip="Set Time" Width="26">
<Button.Background>
<ImageBrush x:Name="TimeImageBrush" ImageSource="/YCS;component/Images/Clock.png" Stretch="Uniform" TileMode="None" />
</Button.Background>
</Button>
Button.Background プロパティの ImageBrush を、アイテムソースから簡単にバインドできる HasHours という名前のブール値に従って別のものに設定するトリガーを作成する必要があります。この物件に……。
私はこのようなことを試しました
<Button.Triggers>
<DataTrigger Binding="{Binding HasHours}" Value="false">
<Setter TargetName="TimeImageBrush" Property="ImageSource" Value="/YCS;component/Images/ClockRed.png"/>
</DataTrigger>
</Button.Triggers>
しかし、それは私にこのエラーを与えます:
タイプ「ContentPresenter」で静的メンバー「ImageSourceProperty」が見つかりません。
どんな助けでも大歓迎です