Files
TheXamlGuy/UI/WPF/Helpers/PropertyPathHelper.cs
T
2022-11-01 15:26:08 +00:00

29 lines
830 B
C#

using System.Windows;
using System.Windows.Data;
namespace TheXamlGuy.UI.WPF
{
public static class PropertyPathHelper
{
private static readonly Dummy dummy = new();
public static object GetValue(object args, string path)
{
Binding binding = new(path)
{
Mode = BindingMode.OneTime,
Source = args
};
BindingOperations.SetBinding(dummy, Dummy.ValueProperty, binding);
return dummy.GetValue(Dummy.ValueProperty);
}
private class Dummy : DependencyObject
{
public static readonly DependencyProperty ValueProperty =
DependencyProperty.Register("Value", typeof(object), typeof(Dummy),
new UIPropertyMetadata(null));
}
}
}