Я все еще новичок в разработке приложений для Windows.
Я пытаюсь создать кнопку динамически и не знаю, как удалить цвет фона по умолчанию при наведении курсора и добавить вместо этого выберите собственный цвет фона.
В моем
Код: Выделить всё
XAML
Код: Выделить всё
Код: Выделить всё
c#. Вот мой код:
var style = new Style
{
TargetType = typeof(Border),
Setters = { new Setter { Property = Border.CornerRadiusProperty, Value = new CornerRadius(4) } }
};
Button button = new Button();
button.Content = "Click Here";
button.Background = new SolidColorBrush(Colour.red);
button.Foreground = new SolidColorBrush(Colour.white);
button.Resources.Add(style.TargetType, style);
Источник: https://stackoverflow.com/questions/781 ... pf-c-sharp