mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-01-17 06:00:38 +01:00
Fixed casting bug in DependencyPropertyHelper
This commit is contained in:
parent
8b08a3b8e6
commit
d863c374c7
|
|
@ -71,7 +71,13 @@ namespace MapControl
|
|||
|
||||
if (changed != null)
|
||||
{
|
||||
metadata.PropertyChangedCallback = (o, e) => changed((FrameworkElement)o, (TValue)e.OldValue, (TValue)e.NewValue);
|
||||
metadata.PropertyChangedCallback = (o, e) =>
|
||||
{
|
||||
if (o is FrameworkElement element)
|
||||
{
|
||||
changed(element, (TValue)e.OldValue, (TValue)e.NewValue);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return DependencyProperty.RegisterAttached(name, typeof(TValue), typeof(TOwner), metadata);
|
||||
|
|
|
|||
|
|
@ -34,9 +34,15 @@ namespace MapControl
|
|||
Action<FrameworkElement, TValue, TValue> changed = null,
|
||||
bool inherits = false) // unused in WinUI/UWP
|
||||
{
|
||||
var metadata = changed != null
|
||||
? new PropertyMetadata(defaultValue, (o, e) => changed((FrameworkElement)o, (TValue)e.OldValue, (TValue)e.NewValue))
|
||||
: new PropertyMetadata(defaultValue);
|
||||
var metadata = changed == null
|
||||
? new PropertyMetadata(defaultValue)
|
||||
: new PropertyMetadata(defaultValue, (o, e) =>
|
||||
{
|
||||
if (o is FrameworkElement element)
|
||||
{
|
||||
changed(element, (TValue)e.OldValue, (TValue)e.NewValue);
|
||||
}
|
||||
});
|
||||
|
||||
return DependencyProperty.RegisterAttached(name, typeof(TValue), typeof(TOwner), metadata);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue