Here I am again.
So a week or 2 ago I was working on a project with my own usercontrol what has to be a button with a image and some text. I got it implemented in my program nicely and the events work like a charm but now I'd like to make it a little more eye catching.
I'm looking for a way to have a mouseenter and mouseleave event. Right now I can change the thickness of the border in my usercontrol this way:
Now I was wondering, is it possible to have a effect like with the normal buttons? Also, there appears to be something like triggers I found on google. With those trigger you should be able to add a storyboard (some animation if I'm right) to the control.
Let's say, I want to have my control (all of it, some overlay) turn green in 2 seconds when entering and back to normal in 2 seconds while leaving it, what would be the best way to do this? I have no experience at all with this and I'm not asking for code. I tried to search for tutorials on the internet but haven't found a good one that's working.
I did try this to change the thickness of my border but no result:
I did remove the 2 events and properties in my Border.xaml.cs.
So a week or 2 ago I was working on a project with my own usercontrol what has to be a button with a image and some text. I got it implemented in my program nicely and the events work like a charm but now I'd like to make it a little more eye catching.
I'm looking for a way to have a mouseenter and mouseleave event. Right now I can change the thickness of the border in my usercontrol this way:
// Button.xaml <Border BorderThickness="{Binding BorderThick, Mode=OneWay}" BorderBrush="Black" > // Button.xaml.cs private int _BorderThickness = 1; public int BorderThick { get { return _BorderThickness; } set { _BorderThickness = value; NotifyPropertyChanged("BorderThick"); } } private void ControlEnter(object sender, MouseEventArgs e) { BorderThick = 5; } private void ControlLeave(object sender, MouseEventArgs e) { BorderThick = 1; }
Now I was wondering, is it possible to have a effect like with the normal buttons? Also, there appears to be something like triggers I found on google. With those trigger you should be able to add a storyboard (some animation if I'm right) to the control.
Let's say, I want to have my control (all of it, some overlay) turn green in 2 seconds when entering and back to normal in 2 seconds while leaving it, what would be the best way to do this? I have no experience at all with this and I'm not asking for code. I tried to search for tutorials on the internet but haven't found a good one that's working.
I did try this to change the thickness of my border but no result:
// Button.waml <UserControl.Style> <Style> <Style.Triggers> <EventTrigger RoutedEvent="Mouse.MouseEnter"> <EventTrigger.Actions> <BeginStoryboard> <Storyboard BeginTime="0:0:0.0" Storyboard.TargetName="bordertest" Storyboard.TargetProperty="BorderThickness"> <DoubleAnimation To="5" Duration="0:0:2.0"/> </Storyboard> </BeginStoryboard> </EventTrigger.Actions> </EventTrigger> </Style.Triggers> </Style> </UserControl.Style> <Border x:Name="bordertest" BorderThickness="{Binding BorderThick, Mode=OneWay}" BorderBrush="Black" >
I did remove the 2 events and properties in my Border.xaml.cs.