Files
docs-desktop/dotnet-desktop-guide/net/wpf/properties/snippets/how-to-implement-a-dependency-property/csharp/MainWindow.xaml.cs
T
2021-10-22 11:09:30 -07:00

31 lines
847 B
C#

using System.Windows;
namespace CodeSampleCsharp
{
/// <summary>
/// Interaction logic for MainWindow.xaml.
/// </summary>
public partial class MainWindow : Window
{
public MainWindow() => InitializeComponent();
}
// <DefineDependencyProperty>
public class Aquarium : DependencyObject
{
public static readonly DependencyProperty HasFishProperty =
DependencyProperty.Register(
name: "HasFish",
propertyType: typeof(bool),
ownerType: typeof(Aquarium),
typeMetadata: new FrameworkPropertyMetadata(defaultValue: false));
public bool HasFish
{
get => (bool)GetValue(HasFishProperty);
set => SetValue(HasFishProperty, value);
}
}
// </DefineDependencyProperty>
}