views:

21

answers:

1

i have a simple button whom i want to switch his template(or style ...)when he is being preesed

i want to move from this

  <DataTemplate>
                     <Button 
                                Click="Button_Click"
                                DataContext="{Binding}"
                                     Height="65" Width="79"
                                Background="Black"
                                Content="{Binding Path=CardWasFounded}"/>
                        </DataTemplate>

to this :

<Button 
                                Click="Button_Click"
                                DataContext="{Binding}"
                                     Height="65" Width="79"
                                Background="{Binding Path=ButtonColor}"
                                Content="{Binding Path=CardWasFounded}"/>
                        </DataTemplate>

EDIT

after i have done

    <Button 
                                Name="btn"
                                Click="Button_Click"
                                DataContext="{Binding}"
                                    Height="65" Width="79"
                                Background="Black"/>

                                <DataTemplate.Triggers>
                                <Trigger SourceName="btn" Property="IsMouseCaptured" Value="True" >
                                    <Setter TargetName="btn" Property="Background" Value="Green"/>
                                    <!--"{Binding Path=ButtonColor}"-->
                                </Trigger>
                                </DataTemplate.Triggers>

it's still doesn't work I think it's because the .net default or something when the mouse is over the button its get's the blue defult color insted of my green or my binding ...

my goal its when its clicked to hook up a binding to color and a storyboard can someone help me achive it ?

+1  A: 

You can achieve this effect with a trigger. You could set a trigger that changes the Background property to your desired value when the button's IsPressed property (or some similar property) equals true.

For more information, take a look at: http://en.csharp-online.net/WPF_Styles_and_Control_Templates%E2%80%94Property_Triggers

Ben Gribaudo
thank you it's the right path but it's doesnt work
yoav.str
Hum...I wonder if this answer would help you in disabling the default animation: http://stackoverflow.com/questions/2687271/wpf-styles-button-mouseover-question
Ben Gribaudo
thank you i posted it as a question by itself ...
yoav.str