I have a ContentPane which I set the BorderThickness to 0 for because of the styling (the border in the middle of whitespace looks bad). However, when the pane is in a floating window (undocked), I would like the border back so you can see the edge over the rest of the app. I thought to make a style trigger, but I can't find an appropriate property to use.
Is there a way I can make this happen?
I was able to achieve what I wanted with this behavior:
internal class PaneToolWindowBorderBehavior : Behavior<ContentPane> { #region Event Handlers protected override void OnAttached () { base.OnAttached();
base.AssociatedObject.MouseEnter += MouseEnter; base.AssociatedObject.DragEnter += MouseEnter; }
protected override void OnDetaching () { base.OnDetaching();
base.AssociatedObject.MouseEnter -= MouseEnter; base.AssociatedObject.DragEnter -= MouseEnter; }
private void MouseEnter (object sender, RoutedEventArgs e) { if (!(Utilities.GetAncestorFromType(base.AssociatedObject as DependencyObject, typeof(PaneToolWindow), true) is null)) { base.AssociatedObject.BorderThickness = new Thickness(1.0); } else { base.AssociatedObject.BorderThickness = new Thickness(0.0); } } #endregion }
Hello Walter,
Thank you for the update. And thank you for sharing your solution to this behavior.