WPF Style: how to change GradientStop Color in Trigger

Posted by Nike on Stack Overflow See other posts from Stack Overflow or by Nike
Published on 2010-03-21T16:38:32Z Indexed on 2010/03/21 16:41 UTC
Read the original article Hit count: 347

Filed under:
|
|
|

I have a Button Style:

<Style x:Key="ButtonStyle1" TargetType="{x:Type Button}">
  <Setter Property="Template">
    <Setter.Value>
      <ControlTemplate TargetType="{x:Type Button}">
        <Grid>
          <Path x:Name="path1" ... Data="...some data...">
            <Path.Fill>
              <LinearGradientBrush EndPoint="0.5,-0.3" StartPoint="0.5,0.8">
                <GradientStop x:Name="gs1" Color="Green" Offset="0.44"/>
                <GradientStop Color="Black" Offset="0.727"/>
              </LinearGradientBrush>
            </Path.Fill>
          </Path>                            
        <ContentPresenter ...properties...   />
      </Grid>

     <ControlTemplate.Triggers>
       <Trigger Property="IsMouseOver" Value="True">
         <Setter TargetName="???" Property="Color" Value="Green"></Setter>
       </Trigger>
     </ControlTemplate.Triggers>
   </ControlTemplate>
 </Setter.Value>

I want to change the Color of GradientStop with x:Name="gs1" when mouse is over button, so I use Trigger IsMouseOver. How can i get an access to Color Property in Trigger? I tried TargetName="path1.gs1" but it doesn't work. Any idea?

© Stack Overflow or respective owner

Related posts about wpf

Related posts about button