diff --git a/HandyControl/Controls/Attach/LinkElement.cs b/HandyControl/Controls/Attach/LinkElement.cs index 90bd8053..5da5d111 100644 --- a/HandyControl/Controls/Attach/LinkElement.cs +++ b/HandyControl/Controls/Attach/LinkElement.cs @@ -29,11 +29,10 @@ namespace HandyControl.Controls private static void CreateTrriger(UIElement element, string link) { - if (string.IsNullOrEmpty(link)) - { - element.CommandBindings.Remove(GetCommandBinding(element)); - return; - } + element.CommandBindings.Remove(GetCommandBinding(element)); + element.SetCurrentValue(CommandBindingProperty, DependencyProperty.UnsetValue); + + if (string.IsNullOrEmpty(link)) return; var commandBinding = new CommandBinding(ControlCommands.OpenLink, (sender, args) => Process.Start(link)); SetCommandBinding(element, commandBinding); element.CommandBindings.Add(commandBinding); diff --git a/HandyControl/Controls/Attach/PanelElement.cs b/HandyControl/Controls/Attach/PanelElement.cs new file mode 100644 index 00000000..f1788378 --- /dev/null +++ b/HandyControl/Controls/Attach/PanelElement.cs @@ -0,0 +1,44 @@ +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); + panel.SetCurrentValue(TempFluidMoveBehaviorProperty, DependencyProperty.UnsetValue); + + 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); + } +} \ No newline at end of file diff --git a/HandyControl/Data/ValueBoxes.cs b/HandyControl/Data/ValueBoxes.cs index 4536ee0d..9954517f 100644 --- a/HandyControl/Data/ValueBoxes.cs +++ b/HandyControl/Data/ValueBoxes.cs @@ -17,6 +17,8 @@ internal static object Double100Box = 100.0; + internal static object Double200Box = 200.0; + internal static object DoubleNeg1Box = -1.0; internal static object Int0Box = 0; diff --git a/HandyControl/HandyControl.csproj b/HandyControl/HandyControl.csproj index 69ec2637..193d91ea 100644 --- a/HandyControl/HandyControl.csproj +++ b/HandyControl/HandyControl.csproj @@ -115,6 +115,7 @@ + @@ -322,6 +323,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/HandyControl/Themes/Basic/Basic.xaml b/HandyControl/Themes/Basic/Basic.xaml index 38b5f704..812f0ae2 100644 --- a/HandyControl/Themes/Basic/Basic.xaml +++ b/HandyControl/Themes/Basic/Basic.xaml @@ -9,6 +9,7 @@ + diff --git a/HandyControl/Themes/Basic/Behaviors.xaml b/HandyControl/Themes/Basic/Behaviors.xaml new file mode 100644 index 00000000..b6454e91 --- /dev/null +++ b/HandyControl/Themes/Basic/Behaviors.xaml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/HandyControlDemo/UserControl/Controls/WaterfallPanelDemoCtl.xaml b/HandyControlDemo/UserControl/Controls/WaterfallPanelDemoCtl.xaml index e6a4b020..a0bc7675 100644 --- a/HandyControlDemo/UserControl/Controls/WaterfallPanelDemoCtl.xaml +++ b/HandyControlDemo/UserControl/Controls/WaterfallPanelDemoCtl.xaml @@ -14,17 +14,7 @@ - - - - - - - - - - - +