File size: 635 Bytes
68dd90e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
using System.Windows;
namespace ScreenGrab.Extensions;
public static class DependencyExtensions
{
#region Public Methods
/// <summary>
/// Sets the value of the <paramref name="property" /> only if it hasn't been explicitly set.
/// </summary>
public static bool SetIfDefault<T>(this DependencyObject o, DependencyProperty property, T value)
{
if (DependencyPropertyHelper.GetValueSource(o, property).BaseValueSource == BaseValueSource.Default)
{
o.SetValue(property, value);
return true;
}
return false;
}
#endregion Public Methods
} |