Witam,napisałem po jakimś czasie i kilku testach Customowy Przycisk na który nałożyłem kilka styli o których przeczytałem w internecie.Wszystko działa pięknie ale gdy się na niego kliknie to świeci się na niebiesko tak jak standardowe przyciski,chciałbym aby po kliknięciu nie było tego efektu,tylko zamiast niego jakiś inny jak np zmiana koloru całej kontrolki na kolor żółty.Wie ktoś jak to zrobić ?
Poniżej zamieszczam kod całego przycisku
CustomButton.xaml
<UserControl x:Class="RPad_2014_Ultimate.CustomButton"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300" Name="btnCustom">
<Button Click="Button_Click_1" Style="{StaticResource CustomButtonStyle}">
<WrapPanel>
<Image Source="{Binding ElementName=btnCustom, Path=ImageSource}"/>
<TextBlock Text="{Binding ElementName=btnCustom, Path=Text}" />
</WrapPanel>
</Button>
</UserControl>
CustomButton.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace RPad_2014_Ultimate
{
/// <summary>
/// Interaction logic for CustomButton.xaml
/// </summary>
public partial class CustomButton : UserControl
{
public CustomButton()
{
InitializeComponent();
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
RaiseEvent(new RoutedEventArgs(ClickEvent));
}
public static readonly DependencyProperty TextProperty =
DependencyProperty.Register("Text", typeof(String),
typeof(CustomButton), new FrameworkPropertyMetadata(string.Empty));
public String Text
{
get { return GetValue(TextProperty).ToString(); }
set { SetValue(TextProperty, value); }
}
public static readonly DependencyProperty ImageSourceProperty =
DependencyProperty.Register("ImageSource", typeof(ImageSource),
typeof(CustomButton), new FrameworkPropertyMetadata(null));
public ImageSource ImageSource
{
get { return GetValue(ImageSourceProperty) as ImageSource; }
set { SetValue(ImageSourceProperty, value); }
}
public static readonly RoutedEvent ClickEvent =
EventManager.RegisterRoutedEvent("Click", RoutingStrategy.Bubble,
typeof(RoutedEventHandler), typeof(CustomButton));
public event RoutedEventHandler Click
{
add { AddHandler(ClickEvent, value); }
remove { RemoveHandler(ClickEvent, value); }
}
}
}
Theme.xaml
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style x:Key="CustomButtonStyle" TargetType="Button">
<Setter Property="BorderBrush" Value="Black" />
<Setter Property="Background" Value="#FFF" />
<Setter Property="Padding" Value="4" />
<Style.Resources>
<Style TargetType="TextBlock">
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
</Style.Resources>
</Style>
</ResourceDictionary>