diff --git a/dotnet-desktop-guide/net/wpf/properties/snippets/collection-type-dependency-properties/csharp/MainWindow.xaml.cs b/dotnet-desktop-guide/net/wpf/properties/snippets/collection-type-dependency-properties/csharp/MainWindow.xaml.cs index 4e9c314..ab9914b 100644 --- a/dotnet-desktop-guide/net/wpf/properties/snippets/collection-type-dependency-properties/csharp/MainWindow.xaml.cs +++ b/dotnet-desktop-guide/net/wpf/properties/snippets/collection-type-dependency-properties/csharp/MainWindow.xaml.cs @@ -69,20 +69,17 @@ namespace CodeSampleCsharp public class Aquarium : DependencyObject { // Register a dependency property with the specified property name, - // property type, and owner type. - private static readonly DependencyProperty s_aquariumContentsProperty = + // property type, and owner type. Store the dependency property + // identifier as a public static readonly member of the class. + public static readonly DependencyProperty AquariumContentsProperty = DependencyProperty.Register( name: "AquariumContents", propertyType: typeof(List), ownerType: typeof(Aquarium) ); - // Store the dependency property identifier as a static member of the class. - public static readonly DependencyProperty AquariumContentsProperty = - s_aquariumContentsProperty; - // Set the default collection value in a class constructor. - public Aquarium() => SetValue(s_aquariumContentsProperty, new List()); + public Aquarium() => SetValue(AquariumContentsProperty, new List()); // Declare a read-write property. public List AquariumContents diff --git a/dotnet-desktop-guide/net/wpf/properties/snippets/collection-type-dependency-properties/vb/MainWindow.xaml.vb b/dotnet-desktop-guide/net/wpf/properties/snippets/collection-type-dependency-properties/vb/MainWindow.xaml.vb index e031016..4743b19 100644 --- a/dotnet-desktop-guide/net/wpf/properties/snippets/collection-type-dependency-properties/vb/MainWindow.xaml.vb +++ b/dotnet-desktop-guide/net/wpf/properties/snippets/collection-type-dependency-properties/vb/MainWindow.xaml.vb @@ -76,20 +76,17 @@ Inherits DependencyObject ' Register a dependency property with the specified property name, - ' property type, and owner type. - Private Shared ReadOnly s_aquariumContentsProperty As DependencyProperty = + ' property type, and owner type. Store the dependency property + ' identifier as a static member of the class. + Public Shared ReadOnly AquariumContentsProperty As DependencyProperty = DependencyProperty.Register( name:="AquariumContents", propertyType:=GetType(List(Of FrameworkElement)), ownerType:=GetType(Aquarium)) - ' Store the dependency property identifier as a static member of the class. - Public Shared ReadOnly AquariumContentsProperty As DependencyProperty = - s_aquariumContentsProperty - ' Set the default collection value in a class constructor. Public Sub New() - SetValue(s_aquariumContentsProperty, New List(Of FrameworkElement)()) + SetValue(AquariumContentsProperty, New List(Of FrameworkElement)()) End Sub ' Declare a read-write property. diff --git a/dotnet-desktop-guide/net/wpf/properties/snippets/custom-dependency-properties/csharp/MainWindow.xaml.cs b/dotnet-desktop-guide/net/wpf/properties/snippets/custom-dependency-properties/csharp/MainWindow.xaml.cs index 524dc50..8ac43f8 100644 --- a/dotnet-desktop-guide/net/wpf/properties/snippets/custom-dependency-properties/csharp/MainWindow.xaml.cs +++ b/dotnet-desktop-guide/net/wpf/properties/snippets/custom-dependency-properties/csharp/MainWindow.xaml.cs @@ -18,8 +18,9 @@ namespace CodeSampleCsharp // // // Register a dependency property with the specified property name, - // property type, owner type, and property metadata. - private static readonly DependencyProperty s_aquariumGraphicProperty = + // property type, owner type, and property metadata. Store the dependency + // property identifier as a public static readonly member of the class. + public static readonly DependencyProperty AquariumGraphicProperty = DependencyProperty.Register( name: "AquariumGraphic", propertyType: typeof(Uri), @@ -29,14 +30,10 @@ namespace CodeSampleCsharp flags: FrameworkPropertyMetadataOptions.AffectsRender, propertyChangedCallback: new PropertyChangedCallback(OnUriChanged)) ); - - // Store the dependency property identifier as a static member of the class. - public static readonly DependencyProperty AquariumGraphicProperty = - s_aquariumGraphicProperty; // // Declare a read-write property. - public Uri AquariumContents + public Uri AquariumGraphic { get => (Uri)GetValue(AquariumGraphicProperty); set => SetValue(AquariumGraphicProperty, value); diff --git a/dotnet-desktop-guide/net/wpf/properties/snippets/custom-dependency-properties/vb/MainWindow.xaml.vb b/dotnet-desktop-guide/net/wpf/properties/snippets/custom-dependency-properties/vb/MainWindow.xaml.vb index 261803e..7112b45 100644 --- a/dotnet-desktop-guide/net/wpf/properties/snippets/custom-dependency-properties/vb/MainWindow.xaml.vb +++ b/dotnet-desktop-guide/net/wpf/properties/snippets/custom-dependency-properties/vb/MainWindow.xaml.vb @@ -17,8 +17,9 @@ ' ' ' Register a dependency property with the specified property name, - ' property type, owner type, and property metadata. - Private Shared ReadOnly s_aquariumGraphicProperty As DependencyProperty = + ' property type, owner type, and property metadata. Store the dependency + ' property identifier as a public static readonly member of the class. + Public Shared ReadOnly AquariumGraphicProperty As DependencyProperty = DependencyProperty.Register( name:="AquariumGraphic", propertyType:=GetType(Uri), @@ -27,10 +28,6 @@ defaultValue:=New Uri("http://www.contoso.com/aquarium-graphic.jpg"), flags:=FrameworkPropertyMetadataOptions.AffectsRender, propertyChangedCallback:=New PropertyChangedCallback(AddressOf OnUriChanged))) - - ' Store the dependency property identifier as a static member of the class. - Public Shared ReadOnly AquariumGraphicProperty As DependencyProperty = - s_aquariumGraphicProperty ' ' Declare a read-write property.