support for .NET framework 3.5

Still have bugs
This commit is contained in:
NaBian committed 2019-01-21 00:43:10 +08:00
1 parent 5878039e21
commit 7d6b491f25
704 files changed
+48273 -33

No files matched your search

@@ -0,0 +1,43 @@
using System.Windows;
using System.Windows.Controls;
using HandyControl.Interactivity;
namespace HandyControl.Controls
{
public class PanelElement
{
public static readonly DependencyProperty FluidMoveBehaviorProperty = DependencyProperty.RegisterAttached(
"FluidMoveBehavior", typeof(FluidMoveBehavior), typeof(PanelElement), new PropertyMetadata(default(FluidMoveBehavior), OnFluidMoveBehaviorChanged));
private static void OnFluidMoveBehaviorChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is Panel panel)
{
var collection = Interaction.GetBehaviors(panel);
var oldBehavior = GetTempFluidMoveBehavior(panel);
collection.Remove(oldBehavior);
if (e.NewValue is FluidMoveBehavior behavior)
{
collection.Add(behavior);
SetTempFluidMoveBehavior(panel, behavior);
}
}
}
public static void SetFluidMoveBehavior(DependencyObject element, FluidMoveBehavior value)
=> element.SetValue(FluidMoveBehaviorProperty, value);
public static FluidMoveBehavior GetFluidMoveBehavior(DependencyObject element)
=> (FluidMoveBehavior) element.GetValue(FluidMoveBehaviorProperty);
private static readonly DependencyProperty TempFluidMoveBehaviorProperty = DependencyProperty.RegisterAttached(
"TempFluidMoveBehavior", typeof(FluidMoveBehavior), typeof(PanelElement), new PropertyMetadata(default(FluidMoveBehavior)));
private static void SetTempFluidMoveBehavior(DependencyObject element, FluidMoveBehavior value)
=> element.SetValue(TempFluidMoveBehaviorProperty, value);
private static FluidMoveBehavior GetTempFluidMoveBehavior(DependencyObject element)
=> (FluidMoveBehavior) element.GetValue(TempFluidMoveBehaviorProperty);
}
}