| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- // Copyright (c) The Avalonia Project. All rights reserved.
- // Licensed under the MIT license. See licence.md file in the project root for full license information.
- using System;
- using Avalonia.Data;
- namespace Avalonia
- {
- /// <summary>
- /// Base class for avalonia property metadata.
- /// </summary>
- public class PropertyMetadata
- {
- private BindingMode _defaultBindingMode;
- /// <summary>
- /// Initializes a new instance of the <see cref="PropertyMetadata"/> class.
- /// </summary>
- /// <param name="defaultBindingMode">The default binding mode.</param>
- public PropertyMetadata(
- BindingMode defaultBindingMode = BindingMode.Default)
- {
- _defaultBindingMode = defaultBindingMode;
- }
- /// <summary>
- /// Gets the default binding mode for the property.
- /// </summary>
- public BindingMode DefaultBindingMode
- {
- get
- {
- return _defaultBindingMode == BindingMode.Default ?
- BindingMode.OneWay : _defaultBindingMode;
- }
- }
- /// <summary>
- /// Merges the metadata with the base metadata.
- /// </summary>
- /// <param name="baseMetadata">The base metadata to merge.</param>
- /// <param name="property">The property to which the metadata is being applied.</param>
- public virtual void Merge(
- PropertyMetadata baseMetadata,
- AvaloniaProperty property)
- {
- if (_defaultBindingMode == BindingMode.Default)
- {
- _defaultBindingMode = baseMetadata.DefaultBindingMode;
- }
- }
- }
- }
|