Skip to content

Instantly share code, notes, and snippets.

using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
namespace PurpleButtonLib
{
public class PurpleButton : Button
{
public PurpleButton()
{
using System.Windows.Media;
namespace PurpleButtonLib
{
public class AquaPurpleButton : PurpleButton
{
public AquaPurpleButton()
{
Background = Brushes.Aqua;
BorderBrush = Brushes.DarkCyan;
<purpleButtonLib:PurpleButton x:Class="WpfApplication.AquaPurpleButton"
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="25" d:DesignWidth="100"
Background="Aqua" BorderBrush="DarkCyan">
</purpleButtonLib:PurpleButton>
using System.Windows;
using System.Windows.Controls;
namespace DependencyProperties
{
public class HelloMessageButton : Button
{
public static DependencyProperty MessageProperty =
DependencyProperty.Register(nameof(Message),
typeof(string),
public class HelloMessageButton : Button
public string Message
{
get { return (string)GetValue(MessageProperty); }
set { SetValue(MessageProperty, value); }
}
public static DependencyProperty MessageProperty =
DependencyProperty.Register(nameof(Message),
typeof(string),
typeof(HelloMessageButton),
new PropertyMetadata(null));
Click += (o, e) => MessageBox.Show(Message);
<Window x:Class="DependencyProperties.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:DependencyProperties"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Grid.RowDefinitions>
public class AddCalculation : DependencyObject