ControlTemplate.Trigger
のバインディングに関するstackoverflowに関する多くの質問がありましたが、ControlTemplate
のコントロールのdatatrigger
へのバインディングに関する情報は何も実行していません。私ControlTemplate
インサイドDatatrigger for ControlTemplate内の長方形
私はRectangle
を持っています。 depency property
Input1Active
が1に等しい場合を除いて、塗りつぶしは通常赤です。次のコードを試しましたが、正しく動作していないようです。
<Style TargetType="{x:Type local:CustomAxis_IO}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:CustomAxis_IO}">
<Grid
<Rectangle Fill="Red">
<Rectangle.Style>
<Style TargetType="{x:Type Rectangle}">
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource TemplatedParent},Path=Input1Active}" Value="1">
<Setter Property="Fill" Value="Green"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Rectangle.Style>
</Rectangle>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
はどのようにコントロールの依存関係プロパティInput1Active
に長方形のためdatatriggerをバインドすることができますか?